]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Avoid vect_is_simple_use call from vectorizable_reduction
authorRichard Biener <rguenther@suse.de>
Thu, 10 Jul 2025 09:21:26 +0000 (11:21 +0200)
committerRichard Biener <rguenth@gcc.gnu.org>
Thu, 10 Jul 2025 11:10:31 +0000 (13:10 +0200)
When analyzing the reduction cycle we look to determine the
reduction input vector type, for lane-reducing ops we look
at the input but instead of using vect_is_simple_use which
is problematic for SLP we should simply get at the SLP
operands vector type.  If that's not set and we make up one
we should also ensure it stays so.

* tree-vect-loop.cc (vectorizable_reduction): Avoid
vect_is_simple_use and record a vector type if we come
up with one.

gcc/tree-vect-loop.cc

index 7b260c34a846b2f82ac008df78a03e0c970c62d0..8ea0f45d79fc0f73925a7d737c48e024514a34d4 100644 (file)
@@ -7378,23 +7378,20 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
 
          if (lane_reducing_op_p (op.code))
            {
-             enum vect_def_type dt;
-             tree vectype_op;
-
              /* The last operand of lane-reducing operation is for
                 reduction.  */
              gcc_assert (reduc_idx > 0 && reduc_idx == (int) op.num_ops - 1);
 
-             if (!vect_is_simple_use (op.ops[0], loop_vinfo, &dt, &vectype_op))
-               return false;
-
+             slp_tree op_node = SLP_TREE_CHILDREN (slp_for_stmt_info)[0];
+             tree vectype_op = SLP_TREE_VECTYPE (op_node);
              tree type_op = TREE_TYPE (op.ops[0]);
-
              if (!vectype_op)
                {
                  vectype_op = get_vectype_for_scalar_type (loop_vinfo,
                                                            type_op);
-                 if (!vectype_op)
+                 if (!vectype_op
+                     || !vect_maybe_update_slp_op_vectype (op_node,
+                                                           vectype_op))
                    return false;
                }