diff options
author | Owen Anderson <resistor@mac.com> | 2008-08-08 18:00:05 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2008-08-08 18:00:05 +0000 |
commit | b12ab97bbdb86e978bbaba62f3dbb402b53010da (patch) | |
tree | 11b3733d53a09406ad8d7f43ddc73790525f2975 /lib/CodeGen/UnreachableBlockElim.cpp | |
parent | 42ccc21ce7ae392d9a5c2958786190943fe9aae0 (diff) |
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
Diffstat (limited to 'lib/CodeGen/UnreachableBlockElim.cpp')
-rw-r--r-- | lib/CodeGen/UnreachableBlockElim.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/CodeGen/UnreachableBlockElim.cpp b/lib/CodeGen/UnreachableBlockElim.cpp index 57811cab0f..152f2f84e8 100644 --- a/lib/CodeGen/UnreachableBlockElim.cpp +++ b/lib/CodeGen/UnreachableBlockElim.cpp @@ -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(); @@ -162,15 +168,9 @@ bool UnreachableMachineBlockElim::runOnMachineFunction(MachineFunction &F) { if (Input != Output) F.getRegInfo().replaceRegWith(Output, Input); - + 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; } |