[llvm-branch-commits] [llvm-branch] r69122 - /llvm/branches/Apple/Dib/lib/Transforms/Scalar/CondPropagate.cpp

Bill Wendling isanbard at gmail.com
Tue Apr 14 17:55:47 PDT 2009


Author: void
Date: Tue Apr 14 19:55:36 2009
New Revision: 69122

URL: http://llvm.org/viewvc/llvm-project?rev=69122&view=rev
Log:
--- Merging (from foreign repository) r69121 into '.':
U    lib/Transforms/Scalar/CondPropagate.cpp

Avoid making the transformation enabled by my last patch if the new destinations
have phi nodes.

Modified:
    llvm/branches/Apple/Dib/lib/Transforms/Scalar/CondPropagate.cpp

Modified: llvm/branches/Apple/Dib/lib/Transforms/Scalar/CondPropagate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Transforms/Scalar/CondPropagate.cpp?rev=69122&r1=69121&r2=69122&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/Transforms/Scalar/CondPropagate.cpp (original)
+++ llvm/branches/Apple/Dib/lib/Transforms/Scalar/CondPropagate.cpp Tue Apr 14 19:55:36 2009
@@ -267,11 +267,21 @@
     // Change FromBr to branch to the new destination.
     FromBr->setSuccessor(0, ToBB);
   } else {
+    BasicBlock *Succ0 = BI->getSuccessor(0);
+    // Do not perform transform if the new destination has PHI nodes. The
+    // transform will add new preds to the PHI's.
+    if (isa<PHINode>(Succ0->begin()))
+      return false;
+
+    BasicBlock *Succ1 = BI->getSuccessor(1);
+    if (isa<PHINode>(Succ1->begin()))
+      return false;
+
     // Insert the new conditional branch.
-    BranchInst::Create(BI->getSuccessor(0), BI->getSuccessor(1), Cond, FromBr);
+    BranchInst::Create(Succ0, Succ1, Cond, FromBr);
 
-    FoldSingleEntryPHINodes(BI->getSuccessor(0));
-    FoldSingleEntryPHINodes(BI->getSuccessor(1));
+    FoldSingleEntryPHINodes(Succ0);
+    FoldSingleEntryPHINodes(Succ1);
 
     // Update PHI nodes in OldSucc to know that FromBB no longer branches to it.
     OldSucc->removePredecessor(FromBB);





More information about the llvm-branch-commits mailing list