]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-optimization/115537 - ICE with SLP condition reduction vectorization
authorRichard Biener <rguenther@suse.de>
Tue, 18 Jun 2024 12:00:52 +0000 (14:00 +0200)
committerRichard Biener <rguenther@suse.de>
Tue, 18 Jun 2024 13:27:52 +0000 (15:27 +0200)
The condition rejecting "multiple-type" SLP condition reduction lacks
handling EXTRACT_LAST reductions.

PR tree-optimization/115537
* tree-vect-loop.cc (vectorizable_reduction): Also reject
SLP condition reductions of EXTRACT_LAST kind when multiple
statement copies are involved.

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

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

diff --git a/gcc/testsuite/gcc.dg/vect/pr115537.c b/gcc/testsuite/gcc.dg/vect/pr115537.c
new file mode 100644 (file)
index 0000000..99ed467
--- /dev/null
@@ -0,0 +1,19 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-mcpu=neoverse-n1" { target aarch64*-*-* } } */
+
+char *a;
+int b;
+void c()
+{
+  int d = 0, e = 0, f;
+  for (; f; ++f)
+    if (a[f] == 5)
+      ;
+    else if (a[f])
+      e = 1;
+    else
+      d = 1;
+  if (d)
+    if (e)
+      b = 0;
+}
index 7c79e9da1060fe6c01687b872fc88a6e5c26cc3b..eeb75c09e91aaf5f6cdd119e0b29b452f99b915f 100644 (file)
@@ -8083,13 +8083,14 @@ vectorizable_reduction (loop_vec_info loop_vinfo,
 
   if ((reduction_type == COND_REDUCTION
        || reduction_type == INTEGER_INDUC_COND_REDUCTION
-       || reduction_type == CONST_COND_REDUCTION)
+       || reduction_type == CONST_COND_REDUCTION
+       || reduction_type == EXTRACT_LAST_REDUCTION)
       && slp_node
       && SLP_TREE_NUMBER_OF_VEC_STMTS (slp_node) > 1)
     {
       if (dump_enabled_p ())
        dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,
-                        "multiple types in condition reduction reduction.\n");
+                        "multiple types in condition reduction.\n");
       return false;
     }