[llvm-commits] [llvm] r54535 - /llvm/trunk/lib/CodeGen/UnreachableBlockElim.cpp
Owen Anderson
resistor at mac.com
Fri Aug 8 11:00:06 PDT 2008
Author: resistor
Date: Fri Aug 8 13:00:05 2008
New Revision: 54535
URL: http://llvm.org/viewvc/llvm-project?rev=54535&view=rev
Log:
Reduce the entries in a phi before testing it for deadness, because removing the entries might make it dead.
Modified:
llvm/trunk/lib/CodeGen/UnreachableBlockElim.cpp
Modified: llvm/trunk/lib/CodeGen/UnreachableBlockElim.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/UnreachableBlockElim.cpp?rev=54535&r1=54534&r2=54535&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/UnreachableBlockElim.cpp (original)
+++ llvm/trunk/lib/CodeGen/UnreachableBlockElim.cpp Fri Aug 8 13:00:05 2008
@@ -152,6 +152,12 @@
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 @@
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;
}
More information about the llvm-commits
mailing list