diff options
author | Chris Lattner <sabre@nondot.org> | 2006-02-03 03:16:14 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-02-03 03:16:14 +0000 |
commit | 109afed40bec552e4d37115c971e082e79eb0093 (patch) | |
tree | 914975ac38a91ca4f3b6cd6451b0e90150e5830d /lib/CodeGen/VirtRegMap.cpp | |
parent | 133d3100eafed975b92f0714a959be438edcb32a (diff) |
Remove move copies and dead stuff by not clobbering the result reg of a noop copy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@25926 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/VirtRegMap.cpp')
-rw-r--r-- | lib/CodeGen/VirtRegMap.cpp | 33 |
1 files changed, 21 insertions, 12 deletions
diff --git a/lib/CodeGen/VirtRegMap.cpp b/lib/CodeGen/VirtRegMap.cpp index c64c411d37..8b08841ee9 100644 --- a/lib/CodeGen/VirtRegMap.cpp +++ b/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; } |