[llvm-commits] [llvm] r85707 - /llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp

Chris Lattner sabre at nondot.org
Sat Oct 31 21:23:20 PDT 2009


Author: lattner
Date: Sat Oct 31 23:23:20 2009
New Revision: 85707

URL: http://llvm.org/viewvc/llvm-project?rev=85707&view=rev
Log:
strengthen an assumption: RevectorBlockTo knows that PredBB 
ended in an uncond branch because the pass requires BreakCriticalEdges.

However, BCE doesn't eliminate critical adges from indbrs.

Modified:
    llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp?rev=85707&r1=85706&r2=85707&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/CondPropagate.cpp Sat Oct 31 23:23:20 2009
@@ -196,18 +196,20 @@
   // possible, and to avoid invalidating "i".
   for (unsigned i = PN->getNumIncomingValues(); i != 0; --i)
     if (ConstantInt *CI = dyn_cast<ConstantInt>(PN->getIncomingValue(i-1))) {
-      // If we have a constant, forward the edge from its current to its
-      // ultimate destination.
-      unsigned DestCase = SI->findCaseValue(CI);
-      RevectorBlockTo(PN->getIncomingBlock(i-1),
-                      SI->getSuccessor(DestCase));
-      ++NumSwThread;
-
-      // If there were two predecessors before this simplification, or if the
-      // PHI node contained all the same value except for the one we just
-      // substituted, the PHI node may be deleted.  Don't iterate through it the
-      // last time.
-      if (SI->getCondition() != PN) return;
+      BasicBlock *PredBB = PN->getIncomingBlock(i-1);
+      if (isa<BranchInst>(PredBB->getTerminator())) {
+        // If we have a constant, forward the edge from its current to its
+        // ultimate destination.
+        unsigned DestCase = SI->findCaseValue(CI);
+        RevectorBlockTo(PredBB, SI->getSuccessor(DestCase));
+        ++NumSwThread;
+
+        // If there were two predecessors before this simplification, or if the
+        // PHI node contained all the same value except for the one we just
+        // substituted, the PHI node may be deleted.  Don't iterate through it the
+        // last time.
+        if (SI->getCondition() != PN) return;
+      }
     }
 }
 





More information about the llvm-commits mailing list