[llvm-commits] CVS: llvm/lib/Transforms/Utils/SimplifyCFG.cpp

Chris Lattner lattner at cs.uiuc.edu
Fri Dec 10 09:42:44 PST 2004



Changes in directory llvm/lib/Transforms/Utils:

SimplifyCFG.cpp updated: 1.60 -> 1.61
---
Log message:

Fix Regression/Transforms/SimplifyCFG/2004-12-10-SimplifyCFGCrash.ll,
and the failure on make_dparser last night.


---
Diffs of the changes:  (+13 -14)

Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.60 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.61
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.60	Tue Nov 30 01:47:34 2004
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp	Fri Dec 10 11:42:31 2004
@@ -1164,21 +1164,20 @@
   // is a conditional branch, see if we can hoist any code from this block up
   // into our predecessor.
   if (OnlyPred)
-    if (BranchInst *BI = dyn_cast<BranchInst>(OnlyPred->getTerminator())) {
-      // This is guaranteed to be a condbr at this point.
-      assert(BI->isConditional() && "Should have folded bb into pred!");
-      // Get the other block.
-      BasicBlock *OtherBB = BI->getSuccessor(BI->getSuccessor(0) == BB);
-      PI = pred_begin(OtherBB);
-      ++PI;
-      if (PI == pred_end(OtherBB)) {
-        // We have a conditional branch to two blocks that are only reachable
-        // from the condbr.  We know that the condbr dominates the two blocks,
-        // so see if there is any identical code in the "then" and "else"
-        // blocks.  If so, we can hoist it up to the branching block.
-        Changed |= HoistThenElseCodeToIf(BI);
+    if (BranchInst *BI = dyn_cast<BranchInst>(OnlyPred->getTerminator()))
+      if (BI->isConditional()) {
+        // Get the other block.
+        BasicBlock *OtherBB = BI->getSuccessor(BI->getSuccessor(0) == BB);
+        PI = pred_begin(OtherBB);
+        ++PI;
+        if (PI == pred_end(OtherBB)) {
+          // We have a conditional branch to two blocks that are only reachable
+          // from the condbr.  We know that the condbr dominates the two blocks,
+          // so see if there is any identical code in the "then" and "else"
+          // blocks.  If so, we can hoist it up to the branching block.
+          Changed |= HoistThenElseCodeToIf(BI);
+        }
       }
-    }
 
   for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI)
     if (BranchInst *BI = dyn_cast<BranchInst>((*PI)->getTerminator()))






More information about the llvm-commits mailing list