aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2025-05-30 14:11:47 +0200
committerRichard Biener <rguenther@suse.de>2025-06-06 09:53:24 +0200
commit8cb0127dfd3d01d4549f3139b087d1a5966844ee (patch)
treee2dd4e39a0987c4866502efe05e4f50e84c89644
parent09884fa0f90da67915245622254cdfb947b87d37 (diff)
downloadgcc-8cb0127dfd3d01d4549f3139b087d1a5966844ee.zip
gcc-8cb0127dfd3d01d4549f3139b087d1a5966844ee.tar.gz
gcc-8cb0127dfd3d01d4549f3139b087d1a5966844ee.tar.bz2
tree-optimization/120357 - ICE with early break vectorization
When doing early break vectorization of a loop with a conditional reduction the epilog creation code is confused as to before which exit to insert the conditional reduction induction IV update. The following make sure this is done before the main IV exit. PR tree-optimization/120357 * tree-vect-loop.cc (vect_create_epilog_for_reduction): Create the conditional reduction induction IV increment before the main IV exit. * gcc.dg/vect/vect-early-break_136-pr120357.c: New testcase. (cherry picked from commit dce4da51ab66c3abb84448326910cd42f6fe2499)
-rw-r--r--gcc/testsuite/gcc.dg/vect/vect-early-break_136-pr120357.c13
-rw-r--r--gcc/tree-vect-loop.cc3
2 files changed, 15 insertions, 1 deletions
diff --git a/gcc/testsuite/gcc.dg/vect/vect-early-break_136-pr120357.c b/gcc/testsuite/gcc.dg/vect/vect-early-break_136-pr120357.c
new file mode 100644
index 0000000..8a51cfc
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/vect/vect-early-break_136-pr120357.c
@@ -0,0 +1,13 @@
+/* { dg-do compile } */
+/* { dg-add-options vect_early_break } */
+/* { dg-additional-options "-O3" } */
+
+char a;
+unsigned long long t[2][22];
+int u[22];
+void f(void)
+{
+ for (int v = 0; v < 22; v++)
+ for (_Bool w = 0; w < (u[v] < 0) + 1; w = 1)
+ a *= 0 != t[w][v];
+}
diff --git a/gcc/tree-vect-loop.cc b/gcc/tree-vect-loop.cc
index 2d35fa1..c824b5a 100644
--- a/gcc/tree-vect-loop.cc
+++ b/gcc/tree-vect-loop.cc
@@ -6189,7 +6189,8 @@ vect_create_epilog_for_reduction (loop_vec_info loop_vinfo,
/* Create an induction variable. */
gimple_stmt_iterator incr_gsi;
bool insert_after;
- vect_iv_increment_position (loop_exit, &incr_gsi, &insert_after);
+ vect_iv_increment_position (LOOP_VINFO_IV_EXIT (loop_vinfo),
+ &incr_gsi, &insert_after);
create_iv (series_vect, PLUS_EXPR, vec_step, NULL_TREE, loop, &incr_gsi,
insert_after, &indx_before_incr, &indx_after_incr);