mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-14 15:39:06 +00:00
Spill mode: Hoist back-copies locally.
The leaveIntvAfter() function normally inserts a back-copy after the requested instruction, making the back-copy kill the live range. In spill mode, try to insert the back-copy before the last use instead. That means the last use becomes the kill instead of the back-copy. This lowers the register pressure because the last use can now redefine the same register it was reading. This will also improve compile time: The back-copy isn't a kill, so hoisting it in hoistCopiesForSize() won't force a recomputation of the source live range. Similarly, if the back-copy isn't hoisted by the splitter, the spiller will not attempt hoisting it locally. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139883 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
69cf1cac3f
commit
ebac0c1747
@ -520,17 +520,28 @@ SlotIndex SplitEditor::leaveIntvAfter(SlotIndex Idx) {
|
||||
DEBUG(dbgs() << " leaveIntvAfter " << Idx);
|
||||
|
||||
// The interval must be live beyond the instruction at Idx.
|
||||
Idx = Idx.getBoundaryIndex();
|
||||
VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Idx);
|
||||
SlotIndex Boundary = Idx.getBoundaryIndex();
|
||||
VNInfo *ParentVNI = Edit->getParent().getVNInfoAt(Boundary);
|
||||
if (!ParentVNI) {
|
||||
DEBUG(dbgs() << ": not live\n");
|
||||
return Idx.getNextSlot();
|
||||
return Boundary.getNextSlot();
|
||||
}
|
||||
DEBUG(dbgs() << ": valno " << ParentVNI->id << '\n');
|
||||
|
||||
MachineInstr *MI = LIS.getInstructionFromIndex(Idx);
|
||||
MachineInstr *MI = LIS.getInstructionFromIndex(Boundary);
|
||||
assert(MI && "No instruction at index");
|
||||
VNInfo *VNI = defFromParent(0, ParentVNI, Idx, *MI->getParent(),
|
||||
|
||||
// In spill mode, make live ranges as short as possible by inserting the copy
|
||||
// before MI. This is only possible if that instruction doesn't redefine the
|
||||
// value. The inserted COPY is not a kill, and we don't need to recompute
|
||||
// the source live range. The spiller also won't try to hoist this copy.
|
||||
if (SpillMode && !SlotIndex::isSameInstr(ParentVNI->def, Idx) &&
|
||||
MI->readsVirtualRegister(Edit->getReg())) {
|
||||
forceRecompute(0, ParentVNI);
|
||||
defFromParent(0, ParentVNI, Idx, *MI->getParent(), MI);
|
||||
return Idx;
|
||||
}
|
||||
|
||||
VNInfo *VNI = defFromParent(0, ParentVNI, Boundary, *MI->getParent(),
|
||||
llvm::next(MachineBasicBlock::iterator(MI)));
|
||||
return VNI->def;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user