[PATCH] D118676: [RS4GC] Extract rematerilazable candidate search. NFC.

Philip Reames via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 2 16:12:54 PST 2022


reames accepted this revision.
reames added a comment.
This revision is now accepted and ready to land.

LGTM to this patch.  All of my style/code concerns had good justifications.

On the general topic, I was thinking of remat slightly differently.  You broke down the indexing expression into the component pieces (Scale, Idx, Disp).  I was thinking about simply computing (Ptr-Base) or RawOffset.  RawOffset might be factorable into component pieces, but I wasn't thinking in terms of extending the live ranges of those pieces.

Instead, I was thinking of rewriting this code:
base = ...
p = some_offset_function(base)
...
use (p)

Into 
base = ...
rawoffset = some_offset_function(base) - p
...
p = base + rawoffset
use (p)

With this form, p+rawOffset should reliable fold into use (for memory uses at least), and the live range of rawoffset is exactly the same as the original p.  We do have an extra variable in the sub-expression, but that's very localized register pressure as the variable for some_offset_function extends one instruction (sub) past the original definition of p.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118676/new/

https://reviews.llvm.org/D118676



More information about the llvm-commits mailing list