]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid ICE with pointer reduction
authorRichard Biener <rguenther@suse.de>
Fri, 31 May 2024 13:17:10 +0000 (15:17 +0200)
committerRichard Biener <rguenther@suse.de>
Mon, 3 Jun 2024 07:24:24 +0000 (09:24 +0200)
There's another case where we can refer to neutral_op before
eventually converting it from pointer to integer so simply
do that unconditionally.

* tree-vect-loop.cc (get_initial_defs_for_reduction):
Always convert neutral_op.

gcc/tree-vect-loop.cc

index 5b85cffb37f224bab9a585e6e7f0d5c9e22f5227..b6e0b9616d521f8d2e2baddd6a497e93a4291f0e 100644 (file)
@@ -5606,6 +5606,12 @@ get_initial_defs_for_reduction (loop_vec_info loop_vinfo,
   tree_vector_builder elts (vector_type, nunits, 1);
   elts.quick_grow (nunits);
   gimple_seq ctor_seq = NULL;
+  if (neutral_op
+      && !useless_type_conversion_p (TREE_TYPE (vector_type),
+                                    TREE_TYPE (neutral_op)))
+    neutral_op = gimple_convert (&ctor_seq,
+                                TREE_TYPE (vector_type),
+                                neutral_op);
   for (j = 0; j < nunits * number_of_vectors; ++j)
     {
       tree op;
@@ -5614,14 +5620,7 @@ get_initial_defs_for_reduction (loop_vec_info loop_vinfo,
       /* Get the def before the loop.  In reduction chain we have only
         one initial value.  Else we have as many as PHIs in the group.  */
       if (i >= initial_values.length () || (j > i && neutral_op))
-       {
-         if (!useless_type_conversion_p (TREE_TYPE (vector_type),
-                                         TREE_TYPE (neutral_op)))
-           neutral_op = gimple_convert (&ctor_seq,
-                                        TREE_TYPE (vector_type),
-                                        neutral_op);
-         op = neutral_op;
-       }
+       op = neutral_op;
       else
        {
          if (!useless_type_conversion_p (TREE_TYPE (vector_type),