https://gcc.gnu.org/g:65aa46ffc3b06bba3d49b9b8315610c706a1215b

commit r15-858-g65aa46ffc3b06bba3d49b9b8315610c706a1215b
Author: Richard Biener <rguent...@suse.de>
Date:   Mon May 27 11:38:11 2024 +0200

    Fix SLP reduction neutral op value for pointer reductions
    
    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.

Diff:
---
 gcc/tree-vect-loop.cc | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 83c0544b6aa..3b94bb13a8b 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -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),

Reply via email to