]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/123221 - ICE with conversion reduction
authorRichard Biener <rguenther@suse.de>
Tue, 6 Jan 2026 12:25:10 +0000 (13:25 +0100)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 7 Jan 2026 08:18:28 +0000 (09:18 +0100)
The following avoids ICEing with a reduction only consisting of
noop-conversions.

PR tree-optimization/123221
* tree-vect-loop.cc (vectorizable_reduction): When we did not
find the non-conversion reduction operation, bail.

* gcc.dg/vect/vect-pr123221.c: New testcase.

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

diff --git a/gcc/testsuite/gcc.dg/vect/vect-pr123221.c b/gcc/testsuite/gcc.dg/vect/vect-pr123221.c
new file mode 100644 (file)
index 0000000..6425179
--- /dev/null
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-fno-tree-pre" } */
+
+int a, d;
+struct {
+  char b;
+} c;
+int main()
+{
+  int f;
+  for (; d; d++)
+    c.b = f = a ? c.b : 0;
+  return 0;
+}
index a82949745e8474d07e8e8e4dc4320495fcc148d4..994d1a3ee749e5cc745bd864b4bc08c93d43ae0f 100644 (file)
@@ -7123,6 +7123,13 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
        }
       reduc_chain_length++;
     }
+  if (!slp_for_stmt_info)
+    {
+      if (dump_enabled_p ())
+       dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
+                        "only noop-conversions in the reduction chain.\n");
+      return false;
+    }
   stmt_info = SLP_TREE_REPRESENTATIVE (slp_for_stmt_info);
 
   /* PHIs should not participate in patterns.  */