https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109441
--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- (In reply to AK from comment #3) > > But IMHO it's academic, right? > > yes. i was just messing with vector codegen. But in case all the elements of > a vector/array are same, maybe the loop can be replaced with equivalent > computation? Yes. GCC doesn't currently have the ability to constant propagate or value-number defs defined by cycles [that actually iterate]. In general doing that is computationally expensive and only in very few cases you can short-cut simulating all iterations (final value replacement does this, but the case in this PR is already too complicated because it involves a memory load). For the case in this PR when simplified to not require removal of all the C++ abstraction via inlining we'd need to handle a loopy memory definition and a loopy memory use. The loopy memory def we can probably pattern match to a memset and the loopy memory use could be (but isn't currently) identified to be always zero. Pass ordering still stands in the way then though.