[llvm-commits] CVS: llvm/lib/CodeGen/RegAllocLocal.cpp
Chris Lattner
lattner at cs.uiuc.edu
Wed Nov 9 10:22:54 PST 2005
Changes in directory llvm/lib/CodeGen:
RegAllocLocal.cpp updated: 1.75 -> 1.76
---
Log message:
Nuke noop copies.
---
Diffs of the changes: (+11 -4)
RegAllocLocal.cpp | 15 +++++++++++----
1 files changed, 11 insertions(+), 4 deletions(-)
Index: llvm/lib/CodeGen/RegAllocLocal.cpp
diff -u llvm/lib/CodeGen/RegAllocLocal.cpp:1.75 llvm/lib/CodeGen/RegAllocLocal.cpp:1.76
--- llvm/lib/CodeGen/RegAllocLocal.cpp:1.75 Tue Nov 8 23:28:45 2005
+++ llvm/lib/CodeGen/RegAllocLocal.cpp Wed Nov 9 12:22:42 2005
@@ -488,9 +488,11 @@
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 @@
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)
More information about the llvm-commits
mailing list