summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2006-02-03 03:16:14 +0000
committerChris Lattner <sabre@nondot.org>2006-02-03 03:16:14 +0000
commite18ef0d4a629ed60d96372c553484e87a37f9d86 (patch)
tree7b0ec6ed5ded71c88c762706e80b6372c93c945c /llvm/lib
parent1318240fd0dad4ab4dd3d6cf55ca050112810060 (diff)
downloadbcm5719-llvm-e18ef0d4a629ed60d96372c553484e87a37f9d86.tar.gz
bcm5719-llvm-e18ef0d4a629ed60d96372c553484e87a37f9d86.zip
Remove move copies and dead stuff by not clobbering the result reg of a noop copy.
llvm-svn: 25926
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/CodeGen/VirtRegMap.cpp33
1 files changed, 21 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/VirtRegMap.cpp b/llvm/lib/CodeGen/VirtRegMap.cpp
index c64c411d379..8b08841ee9c 100644
--- a/llvm/lib/CodeGen/VirtRegMap.cpp
+++ b/llvm/lib/CodeGen/VirtRegMap.cpp
@@ -607,6 +607,15 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, const VirtRegMap &VRM) {
}
if (!OpTakenCareOf) {
+ // Check to see if this is a noop copy. If so, eliminate the
+ // instruction before considering the dest reg to be changed.
+ unsigned Src, Dst;
+ if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) {
+ ++NumDCE;
+ DEBUG(std::cerr << "Removing now-noop copy: " << MI);
+ MBB.erase(&MI);
+ goto ProcessNextInst;
+ }
ClobberPhysReg(VirtReg, SpillSlotsAvailable, PhysRegsAvailable);
continue;
}
@@ -631,6 +640,18 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, const VirtRegMap &VRM) {
DEBUG(std::cerr << "Store:\t" << *next(MII));
MI.SetMachineOperandReg(i, PhysReg);
+ // Check to see if this is a noop copy. If so, eliminate the
+ // instruction before considering the dest reg to be changed.
+ {
+ unsigned Src, Dst;
+ if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) {
+ ++NumDCE;
+ DEBUG(std::cerr << "Removing now-noop copy: " << MI);
+ MBB.erase(&MI);
+ goto ProcessNextInst;
+ }
+ }
+
// If there is a dead store to this stack slot, nuke it now.
MachineInstr *&LastStore = MaybeDeadStores[StackSlot];
if (LastStore) {
@@ -654,18 +675,6 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, const VirtRegMap &VRM) {
++NumStores;
}
}
-
- // Okay, the instruction has been completely processed, input and output
- // registers have been added. As a final sanity check, make sure this is
- // not a noop-copy. If it is, nuke it.
- {
- unsigned Src, Dst;
- if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) {
- ++NumDCE;
- DEBUG(std::cerr << "Removing now-noop copy: " << MI);
- MBB.erase(&MI);
- }
- }
ProcessNextInst:
MII = NextMII;
}
OpenPOWER on IntegriCloud