aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2024-08-06 09:50:00 +0200
committerRichard Biener <rguenth@gcc.gnu.org>2024-08-06 12:49:15 +0200
commit31efd46ad8a16aa671f4502816b6b1f9946027ae (patch)
tree980e7e6c017d2ff6dedac588a874c8fcce1855ca
parentdf4062c54b0b3c5f5c6a1f1a2454abf965100e3a (diff)
downloadgcc-31efd46ad8a16aa671f4502816b6b1f9946027ae.zip
gcc-31efd46ad8a16aa671f4502816b6b1f9946027ae.tar.gz
gcc-31efd46ad8a16aa671f4502816b6b1f9946027ae.tar.bz2
tree-optimization/116241 - ICE with SLP condition reduction
When there's a conversion in front of a SLP condition reduction the code following the reduc-idx SLP chain fails because it assumes there's only COND_EXPRs. PR tree-optimization/116241 * tree-vect-loop.cc (vect_create_epilog_for_reduction): Handle non-COND_EXPR nodes in SLP reduction chain following. * g++.dg/vect/pr116241.cc: New testcase.
-rw-r--r--gcc/testsuite/g++.dg/vect/pr116241.cc13
-rw-r--r--gcc/tree-vect-loop.cc15
2 files changed, 22 insertions, 6 deletions
diff --git a/gcc/testsuite/g++.dg/vect/pr116241.cc b/gcc/testsuite/g++.dg/vect/pr116241.cc
new file mode 100644
index 0000000..7ab1ade
--- /dev/null
+++ b/gcc/testsuite/g++.dg/vect/pr116241.cc
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-additional-options "-O3" } */
+
+short var_27;
+long test_var_5;
+int test_var_6;
+void test(short arr_11[][4][24])
+{
+ for (bool i_6 = 0;;)
+ for (int i_7; i_7;)
+ for (int i_8; i_8 < test_var_5; i_8 += 1)
+ var_27 *= test_var_6 && arr_11[2][1][i_8];
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 856ce49..6456220 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -6075,6 +6075,7 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo,
while (cond_node != slp_node_instance->reduc_phis)
{
stmt_vec_info cond_info = SLP_TREE_REPRESENTATIVE (cond_node);
+ int slp_reduc_idx;
if (gimple_assign_rhs_code (cond_info->stmt) == COND_EXPR)
{
gimple *vec_stmt
@@ -6083,13 +6084,15 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo,
ccompares.safe_push
(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?
- 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
+ /* ??? 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. */
+ slp_reduc_idx = (SLP_TREE_CHILDREN (cond_node).length () - 3
+ STMT_VINFO_REDUC_IDX (cond_info));
+ }
+ else
+ slp_reduc_idx = STMT_VINFO_REDUC_IDX (cond_info);
cond_node = SLP_TREE_CHILDREN (cond_node)[slp_reduc_idx];
}
}