https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114192
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- Created attachment 57600 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=57600&action=edit patch Ah, so the issue is that we only replace the LHS, in this case we pass the reduction stmt for the early exit but the live value is defined by the PHI (we re-start the iteration). That confuses the replacement process. It looks like it might also be wrong for the peeled case on the main edge? The following fixes it for me. Didn't check what happens for the peeled case with a reduction.