summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen
diff options
context:
space:
mode:
authorJakob Stoklund Olesen <stoklund@2pi.dk>2011-09-16 00:03:35 +0000
committerJakob Stoklund Olesen <stoklund@2pi.dk>2011-09-16 00:03:35 +0000
commite2c92a311260fc80909fe75c3a47382976ba937a (patch)
tree39257c2163d9fe0f8960343e8baff021f6891921 /llvm/lib/CodeGen
parente8339b2e633206c991bceacab87e059e652d1b01 (diff)
downloadbcm5719-llvm-e2c92a311260fc80909fe75c3a47382976ba937a.tar.gz
bcm5719-llvm-e2c92a311260fc80909fe75c3a47382976ba937a.zip
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. llvm-svn: 139883
Diffstat (limited to 'llvm/lib/CodeGen')
-rw-r--r--llvm/lib/CodeGen/SplitKit.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/SplitKit.cpp b/llvm/lib/CodeGen/SplitKit.cpp
index 5f7fdccfb6a..63627800af6 100644
--- a/llvm/lib/CodeGen/SplitKit.cpp
+++ b/llvm/lib/CodeGen/SplitKit.cpp
@@ -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;
}
OpenPOWER on IntegriCloud