https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128739
--- Comment #3 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Tamar Christina <[email protected]>: https://gcc.gnu.org/g:69e480fec95e486d9f6d4696f6c55cedf22efe9e commit r17-6321-g69e480fec95e486d9f6d4696f6c55cedf22efe9e Author: Tamar Christina <[email protected]> Date: Mon Nov 16 17:08:42 2026 +0000 vect: restore one condition for IV rewrite on rotated early loops [PR128739] PR128739 exposes a mismatch between the induction and reduction values passed to the scalar epilogue of a peeled early-break loop. For example: unsigned rd (const unsigned char **pp, const unsigned char *lim) { const unsigned char *p = *pp; unsigned s = *p++; unsigned len = s; while (s == 255) { if (p >= lim) return 0; s = *p++; len += s; } *pp = p; return len; } vect_do_peeling already calls vect_update_ivs_after_vectorizer to initialize the scalar IVs from the completed-iteration count. However later, vect_set_loop_condition moves that exit to the latch and overwrites this constraint. Essentially we have: header: acc = PHI <initial, acc_next>; body: acc_next = acc + values; latch: if (finished) goto exit; exit: out = PHI <acc(latch)>; To fix this populate the redirect map with each header PHI's backedge value before copying the exit arguments. The copied PHI then becomes: out = PHI <acc_next(latch)>; gcc/ChangeLog: PR tree-optimization/128739 * tree-vect-loop-manip.cc (vect_set_loop_condition): Use backedge values of header PHIs when copying exit PHI arguments to the latch exit of peeled early-break loops. gcc/testsuite/ChangeLog: PR tree-optimization/128739 * gcc.dg/vect/vect-early-break_151-pr128739.c: New test.
