https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93444
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |rguenth at gcc dot gnu.org Target Milestone|--- |8.4 --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- Isn't this kind-of PR39612? I realize that was store-motion and here's invariant motion. I also note that more aggressively "optimizing" things like _7 = (int) y_21(D); would have allowed propagation of the uninitialized use to a context where it isn't used invariantly. That is, optimize the above to _9(D); introduce an uninit register of 'int' type and optimize (int) y_21(D) to that. Goes away with useful warnings about the uninit use because _9(D) would be unnamed (we could use sth named y as well but it would technically be a different y). For the special case of uninitialized SSA names (but not loads from uninitialized memory as in PR39612) we can "easily" fix LIM here: static class loop * outermost_invariant_loop (tree def, class loop *loop) { ... def_stmt = SSA_NAME_DEF_STMT (def); def_bb = gimple_bb (def_stmt); if (!def_bb) return superloop_at_depth (loop, 1); return NULL if ssa_undefined_value_p (def, true) with a comment explaining things.