The PR120089 fix added more PHIs to LOOP_VINFO_EARLY_BREAKS_LIVE_IVS
but not checking that we only add PHIs with a latch argument. The
following adds this missing check.
PR tree-optimization/120211
* tree-vect-stmts.cc (vect_stmt_relevant_p): Only add PHIs
from the loop header to LOOP_VINFO_EARLY_BREAKS_LIVE_IVS.
* gcc.dg/vect/vect-early-break_135-pr120211.c: New testcase.
* gcc.dg/torture/pr120211-1.c: Likewise.
--- /dev/null
+/* { dg-do compile } */
+
+int a, b, d;
+void e() {
+ do {
+ int f = 0;
+ while (1) {
+ int c = a;
+ for (; (c & 1) == 0; c = 1)
+ for (; c & 1;)
+ ;
+ if (a)
+ break;
+ f++;
+ }
+ b = f & 5;
+ if (b)
+ break;
+ } while (d++);
+}
--- /dev/null
+/* { dg-add-options vect_early_break } */
+/* { dg-additional-options "-O3 -fno-tree-copy-prop -fno-tree-dominator-opts -fno-tree-loop-ivcanon -fno-tree-pre -fno-code-hoisting" } */
+
+int a, b[1];
+int main() {
+ int c = 0;
+ for (; c < 1; c++) {
+ while (a)
+ c++;
+ b[c] = 0;
+ }
+}
alternate exit. */
if (LOOP_VINFO_EARLY_BREAKS (loop_vinfo)
&& is_a <gphi *> (stmt)
+ && gimple_bb (stmt) == LOOP_VINFO_LOOP (loop_vinfo)->header
&& ((! VECTORIZABLE_CYCLE_DEF (STMT_VINFO_DEF_TYPE (stmt_info))
&& ! *live_p)
|| STMT_VINFO_DEF_TYPE (stmt_info) == vect_induction_def))