Reduce the entries in a phi before testing it for deadness, because removing the entries might make it dead.

llvm-svn: 54535
This commit is contained in:
Owen Anderson 2008-08-08 18:00:05 +00:00
parent df8c7faf60
commit dfb0b6952a
1 changed files with 7 additions and 7 deletions

View File

@ -152,6 +152,12 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
MachineBasicBlock::iterator phi = BB->begin();
while (phi != BB->end() &&
phi->getOpcode() == TargetInstrInfo::PHI) {
for (unsigned i = phi->getNumOperands() - 1; i >= 2; i-=2)
if (!preds.count(phi->getOperand(i).getMBB())) {
phi->RemoveOperand(i);
phi->RemoveOperand(i-1);
}
if (phi->getNumOperands() == 3) {
unsigned Input = phi->getOperand(1).getReg();
unsigned Output = phi->getOperand(0).getReg();
@ -166,12 +172,6 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
continue;
}
for (unsigned i = phi->getNumOperands() - 1; i >= 2; i-=2)
if (!preds.count(phi->getOperand(i).getMBB())) {
phi->RemoveOperand(i);
phi->RemoveOperand(i-1);
}
++phi;
}
}