]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Fix SLP reduction neutral op value for pointer reductions
authorRichard Biener <rguenther@suse.de>
Mon, 27 May 2024 09:38:11 +0000 (11:38 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 28 May 2024 08:15:29 +0000 (10:15 +0200)
When the neutral op is the initial value we might need to convert
it from pointer to integer.

* tree-vect-loop.cc (get_initial_defs_for_reduction): Convert
neutral op to the vector component type.

gcc/tree-vect-loop.cc

index 83c0544b6aa54902fa5609e299eeac46d81e753a..3b94bb13a8b087083f083c4d5240cd9402d68046 100644 (file)
@@ -5616,7 +5616,14 @@ 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))
-       op = 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;
+       }
       else
        {
          if (!useless_type_conversion_p (TREE_TYPE (vector_type),