https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121492
--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to Richard Biener from comment #2) > 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. OK, so we're at least keying off "run from PRE" on the walk kind, that would have to be changed.