aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-07-17 11:42:13 +0200
committerRichard Biener <rguenth@gcc.gnu.org>2024-07-17 13:19:41 +0200
commit24689b84b8ec0c74c2b9a72ec4fb467069806bda (patch)
tree22870edf3d20c905e648d0fd6b0514cadb918f30 /gcc
parent2790800c61fb5748cd336e09a691848dd3e74090 (diff)
downloadgcc-24689b84b8ec0c74c2b9a72ec4fb467069806bda.zip
gcc-24689b84b8ec0c74c2b9a72ec4fb467069806bda.tar.gz
gcc-24689b84b8ec0c74c2b9a72ec4fb467069806bda.tar.bz2
tree-optimization/115959 - ICE with SLP condition reduction
The following fixes how during reduction epilogue generation we gather conditional compares for condition reductions, thereby following the reduction chain via STMT_VINFO_REDUC_IDX. The issue is that SLP nodes for COND_EXPRs can have either three or four children dependent on whether we have legacy GENERIC expressions in the transitional pattern GIMPLE for the COND_EXPR condition. PR tree-optimization/115959 * tree-vect-loop.cc (vect_create_epilog_for_reduction): Get at the REDUC_IDX child in a safer way for COND_EXPR nodes. * gcc.dg/vect/pr115959.c: New testcase.
Diffstat (limited to 'gcc')
-rw-r--r--gcc/testsuite/gcc.dg/vect/pr115959.c14
-rw-r--r--gcc/tree-vect-loop.cc10
2 files changed, 21 insertions, 3 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/pr115959.c b/gcc/testsuite/gcc.dg/vect/pr115959.c
new file mode 100644
index 0000000..181d552
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/pr115959.c
@@ -0,0 +1,14 @@
+/* { dg-do compile } */
+
+int a;
+_Bool *b;
+void f()
+{
+ int t = a;
+ for (int e = 0; e < 2048; e++)
+ {
+ if (!b[e])
+ t = 0;
+ }
+ a = t;
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index b8124a3..a464bc8 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -6090,9 +6090,13 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo,
(std::make_pair (gimple_assign_rhs1 (vec_stmt),
STMT_VINFO_REDUC_IDX (cond_info) == 2));
}
- /* ??? We probably want to have REDUC_IDX on the SLP node? */
- cond_node = SLP_TREE_CHILDREN
- (cond_node)[STMT_VINFO_REDUC_IDX (cond_info)];
+ /* ??? We probably want to have REDUC_IDX on the SLP node?
+ We have both three and four children COND_EXPR nodes
+ dependent on whether the comparison is still embedded
+ as GENERIC. So work backwards. */
+ int slp_reduc_idx = (SLP_TREE_CHILDREN (cond_node).length () - 3
+ + STMT_VINFO_REDUC_IDX (cond_info));
+ cond_node = SLP_TREE_CHILDREN (cond_node)[slp_reduc_idx];
}
}
else