Fix thinko. Cmp can be the first instruction in a MBB.

llvm-svn: 125552
This commit is contained in:
Evan Cheng 2011-02-15 05:00:24 +00:00
parent c7bfdcd4f5
commit 98196b4ebb
1 changed files with 5 additions and 2 deletions

View File

@ -331,7 +331,8 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
ImmDefRegs.clear();
ImmDefMIs.clear();
MachineBasicBlock::iterator PMII = I->begin();
bool First = true;
MachineBasicBlock::iterator PMII;
for (MachineBasicBlock::iterator
MII = I->begin(), MIE = I->end(); MII != MIE; ) {
MachineInstr *MI = &*MII;
@ -348,7 +349,7 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
if (OptimizeCmpInstr(MI, MBB)) {
// MI is deleted.
Changed = true;
MII = llvm::next(PMII);
MII = First ? I->begin() : llvm::next(PMII);
continue;
}
}
@ -360,6 +361,8 @@ bool PeepholeOptimizer::runOnMachineFunction(MachineFunction &MF) {
if (SeenMoveImm)
Changed |= FoldImmediate(MI, MBB, ImmDefRegs, ImmDefMIs);
}
First = false;
PMII = MII;
++MII;
}