]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/122292 - fix reduction code gen issue
authorRichard Biener <rguenther@suse.de>
Wed, 15 Oct 2025 14:15:50 +0000 (16:15 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 16 Oct 2025 08:54:30 +0000 (10:54 +0200)
The following fixes a mixup of vector types checked when looking
at a conditional reduction operation.  We want the actual data
vector input type, so look at the SLP trees type instead and
special-case lane-reducing ops like the original code did.

PR tree-optimization/122292
* tree-vect-loop.cc (vect_transform_reduction): Compute the
input vector type the same way the analysis phase does.

gcc/tree-vect-loop.cc

index 97c1bf0809fd345af7b231c29b6ceb997bb18e0d..568353ae5bf5df57a45e029db5fd76462698dbe2 100644 (file)
@@ -7752,7 +7752,9 @@ vect_transform_reduction (loop_vec_info loop_vinfo,
      assumption is not true: we use reduc_index to record the index of the
      reduction variable.  */
   int reduc_index = SLP_TREE_REDUC_IDX (slp_node);
-  tree vectype_in = SLP_TREE_VECTYPE (SLP_TREE_CHILDREN (slp_node)[0]);
+  tree vectype_in = SLP_TREE_VECTYPE (slp_node);
+  if (lane_reducing_op_p (op.code))
+    vectype_in = SLP_TREE_VECTYPE (SLP_TREE_CHILDREN (slp_node)[0]);
 
   vec_num = vect_get_num_copies (loop_vinfo, SLP_TREE_CHILDREN (slp_node)[0]);