Bug fix: some redundant copies were not being deleted after detection :-|.

llvm-svn: 3959
This commit is contained in:
Vikram S. Adve 2002-09-27 14:27:37 +00:00
parent 66303bb9a5
commit d238de02c7
1 changed files with 9 additions and 7 deletions

View File

@ -30,23 +30,25 @@ DeleteInstruction(MachineCodeForBasicBlock& mvec,
const TargetMachine& target) const TargetMachine& target)
{ {
// Check if this instruction is in a delay slot of its predecessor. // Check if this instruction is in a delay slot of its predecessor.
// If so, replace this instruction with a nop, else just delete it.
// By replacing in place, we save having to update the I-I maps.
if (BBI != mvec.begin()) if (BBI != mvec.begin())
{ {
const MachineInstrInfo& mii = target.getInstrInfo(); const MachineInstrInfo& mii = target.getInstrInfo();
MachineInstr* predMI = *(BBI-1); MachineInstr* predMI = *(BBI-1);
if (unsigned ndelay = mii.getNumDelaySlots(predMI->getOpCode())) if (unsigned ndelay = mii.getNumDelaySlots(predMI->getOpCode()))
{ {
// This instruction is in a delay slot of its predecessor, so
// replace it with a nop. By replacing in place, we save having
// to update the I-I maps.
//
assert(ndelay == 1 && "Not yet handling multiple-delay-slot targets"); assert(ndelay == 1 && "Not yet handling multiple-delay-slot targets");
(*BBI)->replace(mii.getNOPOpCode(), 0); (*BBI)->replace(mii.getNOPOpCode(), 0);
return;
} }
} }
else
{ // The instruction is not in a delay slot, so we can simply erase it.
mvec.erase(BBI); mvec.erase(BBI);
BBI = mvec.end(); BBI = mvec.end();
}
} }
//******************* Individual Peephole Optimizations ********************/ //******************* Individual Peephole Optimizations ********************/