mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-09-27 16:17:17 +00:00
Reduce the entries in a phi before testing it for deadness, because removing the entries might make it dead.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54535 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -152,6 +152,12 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
|
|||||||
MachineBasicBlock::iterator phi = BB->begin();
|
MachineBasicBlock::iterator phi = BB->begin();
|
||||||
while (phi != BB->end() &&
|
while (phi != BB->end() &&
|
||||||
phi->getOpcode() == TargetInstrInfo::PHI) {
|
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) {
|
if (phi->getNumOperands() == 3) {
|
||||||
unsigned Input = phi->getOperand(1).getReg();
|
unsigned Input = phi->getOperand(1).getReg();
|
||||||
unsigned Output = phi->getOperand(0).getReg();
|
unsigned Output = phi->getOperand(0).getReg();
|
||||||
@@ -166,12 +172,6 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) {
|
|||||||
continue;
|
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;
|
++phi;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user