https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128739
--- Comment #1 from Ted Rodgers <ted.d.rodgers at gmail dot com> --- When the loop vectorizer handles an early-break loop that also has a counting exit and is versioned for alignment, it moves the counting-exit test from the loop header to the latch, but copies the PHI arguments on that edge unchanged from the old header-position edge. Those arguments are the values at the start of the iteration; at the latch the iteration has completed, so loop-carried live-outs must instead use the backedge values of the header PHIs. As a result the final vector iteration's contribution to a reduction is dropped, while the induction variable — and the epilog resume point — is still advanced past that iteration: the result comes out silently too small, with everything else consistent. The miscompile only manifests on the alignment-versioned path: it fails if p % vector_width == vector_width - 1, i.e. when the initial pointer sits one byte below a vector boundary. buf + 31 hits this for both 16- and 32-byte vectors Note: rd needs the peeled first iteration and a counting exit that returns (not breaks) to hit the buggy path, and the reduction is what goes wrong — p advances correctly, which is why the failure is silent.
