https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95717
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- The bogus def is set via if (scalar_loop != loop) { /* If we copied from SCALAR_LOOP rather than LOOP, SSA_NAMEs from SCALAR_LOOP will have current_def set to SSA_NAMEs in the new_loop, but LOOP will not. slpeel_update_phi_nodes_for_guard{1,2} expects the LOOP SSA_NAMEs (on the exit edge and edge from latch to header) to have current_def set, so copy them over. */ slpeel_duplicate_current_defs_from_edges (single_exit (scalar_loop), exit); because that interferes with the renaming process. The if-conversion applied the missed optimization to the to-be vectorized loop introducing a LC PHI (required for the not if-converted copy) which has one invariant and one non-invariant arg. So we have to do that copying after renaming in the BBs. That seems to work, testing patch.