[PATCH] D40308: [RegisterCoalescer] More fixes for subreg join failure in RegCoalescer
Matthias Braun via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 15 11:48:23 PST 2018
MatzeB accepted this revision.
MatzeB added a comment.
This revision is now accepted and ready to land.
LGTM, with same change to avoid unnecessary repeated shrinkToUses().
================
Comment at: lib/CodeGen/RegisterCoalescer.cpp:620-625
+ // Also deal with subranges
+ for (LiveInterval::SubRange &S : IntA.subranges()) {
+ LiveInterval::iterator SS = S.FindSegmentContaining(CopyUseIdx);
+ if (SS->end == CopyIdx)
+ shrinkToUses(&IntA);
+ }
----------------
You only ever need to do shrinkToUses once as it will deal with all subranges. Therefore I'd propose to change this block to:
```
// Rewrite the copy.
CopyMI->substituteRegister(IntA.reg, IntB.reg, 0, *TRI);
// If the copy instruction was killing the destination register or any
// subrange before the merge trim the live range.
bool RecomputeLiveRange = AS->end == CopyIdx;
if (!RecomputeLiveRange) {
for (LiveInterval::SubRange &S : IntA.subranges()) {
LiveInterval::iterator SS = S.FindSegmentContaining(CopyUseIdx);
if (SS != S.end() && SS->end == CopyIdx) {
RecomputeLiveRange = true;
break;
}
}
}
if (RecomputeLiveRange)
shrinkToUses(&IntA);
```
https://reviews.llvm.org/D40308
More information about the llvm-commits
mailing list