https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121492
--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> --- Huh, but it's not loop invariant, is it? After loop header copying FRE5 manages to optimize the last copy before the return. Before loop header copying the loop form isn't good. PRE does not catch that copy because it runs VN with VN_VALK (rather than VN_WALKREWRITE). I don't remember exactly why though.