]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/122419 - reduction chain with conversion as op
authorRichard Biener <rguenther@suse.de>
Mon, 27 Oct 2025 10:31:32 +0000 (11:31 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Mon, 27 Oct 2025 12:21:39 +0000 (13:21 +0100)
The following deals with reduction detection handling a non-noop
conversion as reduction operation and makes the reduction chain
chain re-discovery handle this situation the same.

PR tree-optimization/122419
* tree-vect-slp.cc (vect_analyze_slp_reduc_chain): Only
skip noop conversions.

* gcc.dg/vect/pr122419.c: New testcase.

gcc/testsuite/gcc.dg/vect/pr122419.c [new file with mode: 0644]
gcc/tree-vect-slp.cc

diff --git a/gcc/testsuite/gcc.dg/vect/pr122419.c b/gcc/testsuite/gcc.dg/vect/pr122419.c
new file mode 100644 (file)
index 0000000..b428cfb
--- /dev/null
@@ -0,0 +1,9 @@
+/* { dg-do compile } */
+
+int a;
+long b;
+void c()
+{
+  for (; b; b--)
+    a = (char)a;
+}
index 31d84857d49347a77d9df4cc0c6a2bc7f90d35cf..e02b3379bb4622c3631e1718e635f5707e3bf0e7 100644 (file)
@@ -4217,6 +4217,7 @@ vect_analyze_slp_reduc_chain (loop_vec_info vinfo,
       if (!gimple_extract_op (STMT_VINFO_STMT (vect_orig_stmt (stmt)), &op))
        gcc_unreachable ();
       if (CONVERT_EXPR_CODE_P (op.code)
+         && tree_nop_conversion_p (op.type, TREE_TYPE (op.ops[0]))
          && (first
              || is_a <gphi *> (STMT_VINFO_STMT (next_stmt))))
        ;