summaryrefslogtreecommitdiff
path: root/lib/CodeGen/RegAllocLocal.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-11-09 18:22:42 +0000
committerChris Lattner <sabre@nondot.org>2005-11-09 18:22:42 +0000
commite6a88ac1b903206c777fdf85e1c2be4b01175107 (patch)
tree93aab098c17125fdb8b66c5527a9105d61250398 /lib/CodeGen/RegAllocLocal.cpp
parent6b2d69655ace2788b244c8a4ebcfb6f2a926ad92 (diff)
downloadllvm-e6a88ac1b903206c777fdf85e1c2be4b01175107.tar.gz
llvm-e6a88ac1b903206c777fdf85e1c2be4b01175107.tar.bz2
llvm-e6a88ac1b903206c777fdf85e1c2be4b01175107.tar.xz
Nuke noop copies.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@24258 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/RegAllocLocal.cpp')
-rw-r--r--lib/CodeGen/RegAllocLocal.cpp15
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/CodeGen/RegAllocLocal.cpp b/lib/CodeGen/RegAllocLocal.cpp
index 184d9e27ba..800f305ad9 100644
--- a/lib/CodeGen/RegAllocLocal.cpp
+++ b/lib/CodeGen/RegAllocLocal.cpp
@@ -488,9 +488,11 @@ MachineInstr *RA::reloadVirtReg(MachineBasicBlock &MBB, MachineInstr *MI,
void RA::AllocateBasicBlock(MachineBasicBlock &MBB) {
// loop over each instruction
- MachineBasicBlock::iterator MI = MBB.begin();
- for (; MI != MBB.end(); ++MI) {
- const TargetInstrDescriptor &TID = TM->getInstrInfo()->get(MI->getOpcode());
+ MachineBasicBlock::iterator MII = MBB.begin();
+ const TargetInstrInfo &TII = *TM->getInstrInfo();
+ while (MII != MBB.end()) {
+ MachineInstr *MI = MII++;
+ const TargetInstrDescriptor &TID = TII.get(MI->getOpcode());
DEBUG(std::cerr << "\nStarting RegAlloc of: " << *MI;
std::cerr << " Regs have values: ";
for (unsigned i = 0; i != RegInfo->getNumRegs(); ++i)
@@ -621,9 +623,14 @@ void RA::AllocateBasicBlock(MachineBasicBlock &MBB) {
removePhysReg(PhysReg);
}
}
+
+ // Finally, if this is a noop copy instruction, zap it.
+ unsigned SrcReg, DstReg;
+ if (TII.isMoveInstr(*MI, SrcReg, DstReg) && SrcReg == DstReg)
+ MBB.erase(MI);
}
- MI = MBB.getFirstTerminator();
+ MachineBasicBlock::iterator MI = MBB.getFirstTerminator();
// Spill all physical registers holding virtual registers now.
for (unsigned i = 0, e = RegInfo->getNumRegs(); i != e; ++i)