https://gcc.gnu.org/g:2f2e9bcfb0fd9cbf46e2d0d03b3f32f7df8d4fff

commit r16-2170-g2f2e9bcfb0fd9cbf46e2d0d03b3f32f7df8d4fff
Author: Richard Biener <rguent...@suse.de>
Date:   Thu Jul 10 11:26:04 2025 +0200

    Handle failed gcond pattern gracefully
    
    SLP analysis of early break conditions asserts pattern recognition
    canonicalized all of them.  But the pattern can fail, for example
    when vector types cannot be computed.  So be graceful here, so
    we don't ICE when we didn't yet compute vector types.
    
            * tree-vect-slp.cc (vect_analyze_slp): Fail for non-canonical
            gconds.

Diff:
---
 gcc/tree-vect-slp.cc | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-vect-slp.cc b/gcc/tree-vect-slp.cc
index 5ef45fd60f57..ad75386926a8 100644
--- a/gcc/tree-vect-slp.cc
+++ b/gcc/tree-vect-slp.cc
@@ -5068,9 +5068,15 @@ vect_analyze_slp (vec_info *vinfo, unsigned 
max_tree_size,
          tree args0 = gimple_cond_lhs (stmt);
          tree args1 = gimple_cond_rhs (stmt);
 
-         /* These should be enforced by cond lowering.  */
-         gcc_assert (gimple_cond_code (stmt) == NE_EXPR);
-         gcc_assert (zerop (args1));
+         /* These should be enforced by cond lowering, but if it failed
+            bail.  */
+         if (gimple_cond_code (stmt) != NE_EXPR
+             || TREE_TYPE (args0) != boolean_type_node
+             || !integer_zerop (args1))
+           {
+             roots.release ();
+             continue;
+           }
 
          /* An argument without a loop def will be codegened from vectorizing 
the
             root gcond itself.  As such we don't need to try to build an SLP 
tree

Reply via email to