https://gcc.gnu.org/g:af0af4cf81307240cafdf642e913128ad7ac6b81

commit r16-3348-gaf0af4cf81307240cafdf642e913128ad7ac6b81
Author: Richard Biener <rguent...@suse.de>
Date:   Fri Aug 22 14:29:49 2025 +0200

    Fixups around reduction info and STMT_VINFO_REDUC_VECTYPE_IN
    
    STMT_VINFO_REDUC_VECTYPE_IN exists on relevant reduction stmts, not
    the reduction info.  And STMT_VINFO_DEF_TYPE exists on the
    reduction info.  The following fixes up a few places.
    
            * tree-vect-loop.cc (vectorizable_lane_reducing): Get
            reduction info properly.  Adjust checks according to
            comments.
            (vectorizable_reduction): Do not set STMT_VINFO_REDUC_VECTYPE_IN
            on the reduc info.
            (vect_transform_reduction): Query STMT_VINFO_REDUC_VECTYPE_IN
            on the actual reduction stmt, not the info.

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

diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index cb66c4d1a53b..d6b5042c08e4 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -6881,16 +6881,17 @@ vectorizable_lane_reducing (loop_vec_info loop_vinfo, 
stmt_vec_info stmt_info,
   if (!type_has_mode_precision_p (type))
     return false;
 
-  stmt_vec_info reduc_info = STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info));
-
   /* TODO: Support lane-reducing operation that does not directly participate
      in loop reduction.  */
-  if (!reduc_info || STMT_VINFO_REDUC_IDX (stmt_info) < 0)
+  if (!STMT_VINFO_REDUC_DEF (vect_orig_stmt (stmt_info))
+      || STMT_VINFO_REDUC_IDX (stmt_info) < 0)
     return false;
 
+  stmt_vec_info reduc_info = info_for_reduction (loop_vinfo, stmt_info);
+
   /* Lane-reducing pattern inside any inner loop of LOOP_VINFO is not
      recoginized.  */
-  gcc_assert (STMT_VINFO_DEF_TYPE (reduc_info) == vect_reduction_def);
+  gcc_assert (!nested_in_vect_loop_p (LOOP_VINFO_LOOP (loop_vinfo), 
stmt_info));
   gcc_assert (STMT_VINFO_REDUC_TYPE (reduc_info) == TREE_CODE_REDUCTION);
 
   for (int i = 0; i < (int) gimple_num_ops (stmt) - 1; i++)
@@ -7281,7 +7282,6 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
 
   tree vectype_out = SLP_TREE_VECTYPE (slp_for_stmt_info);
   STMT_VINFO_REDUC_VECTYPE (reduc_info) = vectype_out;
-  STMT_VINFO_REDUC_VECTYPE_IN (reduc_info) = vectype_in;
 
   gimple_match_op op;
   if (!gimple_extract_op (stmt_info->stmt, &op))
@@ -8205,7 +8205,7 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
            }
        }
 
-      tree reduc_vectype_in = STMT_VINFO_REDUC_VECTYPE_IN (reduc_info);
+      tree reduc_vectype_in = STMT_VINFO_REDUC_VECTYPE_IN (stmt_info);
       gcc_assert (reduc_vectype_in);
 
       unsigned effec_reduc_ncopies

Reply via email to