https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70048
--- Comment #8 from amker at gcc dot gnu.org --- (In reply to Richard Henderson from comment #6) > Created attachment 37886 [details] > proposed patch > > I agree -- at minimum virtual and eliminable frame registers ought to be > special-cased. If we separate the constants too far, we'll never be able > to fold the constant plus the adjustment back together. > > If the statement in #c4 is taken at face value -- that r233136 was applied > to simplify frame-based array accesses... Well, I simply don't believe > that. > > I can see how the patch would aid reduction of access to members of a > structure that are in an array which in turn is *not* on the stack. But > for the average stack-based access I can't see except that it would hurt. Hi Richard, my comment was about when to legitimize address expression in the form of "base + reg << scaling + offset", the gimple passes could be improved to catch CSE opportunities of "reg << scaling" so that base + offset can be moved out of memory reference. it's beneficial since "base_offset" is likely invariant in loop context, especially when the base is sp/fp related. IMHO, this is the same transform as your propose patch does. Or maybe I mis-understood something important? Thanks.