[llvm-commits] CVS: llvm/lib/Transforms/Scalar/CondPropagate.cpp

Devang Patel dpatel at apple.com
Wed Nov 1 14:26:57 PST 2006



Changes in directory llvm/lib/Transforms/Scalar:

CondPropagate.cpp updated: 1.6 -> 1.7
---
Log message:

Handle PHINode with only one incoming value.
This fixes http://llvm.org/bugs/show_bug.cgi?id=979


---
Diffs of the changes:  (+9 -5)

 CondPropagate.cpp |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)


Index: llvm/lib/Transforms/Scalar/CondPropagate.cpp
diff -u llvm/lib/Transforms/Scalar/CondPropagate.cpp:1.6 llvm/lib/Transforms/Scalar/CondPropagate.cpp:1.7
--- llvm/lib/Transforms/Scalar/CondPropagate.cpp:1.6	Sun Aug 27 17:42:52 2006
+++ llvm/lib/Transforms/Scalar/CondPropagate.cpp	Wed Nov  1 16:26:43 2006
@@ -196,11 +196,15 @@
   // Get the old block we are threading through.
   BasicBlock *OldSucc = FromBr->getSuccessor(0);
 
-  // ToBB should not have any PHI nodes in it to update, because OldSucc had
-  // multiple successors.  If OldSucc had multiple successor and ToBB had
-  // multiple predecessors, the edge between them would be critical, which we
-  // already took care of.
-  assert(!isa<PHINode>(ToBB->begin()) && "Critical Edge Found!");
+  // OldSucc had multiple successors. If ToBB has multiple predecessors, the
+  // edge between them would be critical, which we already took care of.
+  // If ToBB has single operand PHI node than take care of it here.
+  if (isa<PHINode>(ToBB->begin())) {
+    PHINode *PN = cast<PHINode>(ToBB->begin());
+    assert(PN->getNumIncomingValues() == 1 && "Critical Edge Found!");    
+    PN->replaceAllUsesWith(PN->getIncomingValue(0));
+    PN->eraseFromParent();
+  }
 
   // Update PHI nodes in OldSucc to know that FromBB no longer branches to it.
   OldSucc->removePredecessor(FromBB);






More information about the llvm-commits mailing list