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

Chris Lattner lattner at cs.uiuc.edu
Mon Sep 23 19:10:01 PDT 2002


Changes in directory llvm/lib/Transforms/Utils:

SimplifyCFG.cpp updated: 1.3 -> 1.4

---
Log message:

Minor cleanups


---
Diffs of the changes:

Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.3 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.4
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.3	Mon Jul 29 16:26:30 2002
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp	Mon Sep 23 19:09:26 2002
@@ -28,7 +28,9 @@
 //
 static bool PropogatePredecessorsForPHIs(BasicBlock *BB, BasicBlock *Succ) {
   assert(*succ_begin(BB) == Succ && "Succ is not successor of BB!");
-  assert(isa<PHINode>(Succ->front()) && "Only works on PHId BBs!");
+
+  if (!isa<PHINode>(Succ->front()))
+    return false;  // We can make the transformation, no problem.
 
   // If there is more than one predecessor, and there are PHI nodes in
   // the successor, then we need to add incoming edges for the PHI nodes
@@ -39,10 +41,9 @@
   // Succ.  If so, we cannot do the transformation!
   //
   for (pred_iterator PI = pred_begin(Succ), PE = pred_end(Succ);
-       PI != PE; ++PI) {
+       PI != PE; ++PI)
     if (find(BBPreds.begin(), BBPreds.end(), *PI) != BBPreds.end())
       return true;
-  }
 
   // Loop over all of the PHI nodes in the successor BB
   for (BasicBlock::iterator I = Succ->begin();
@@ -118,11 +119,8 @@
         // Be careful though, if this transformation fails (returns true) then
         // we cannot do this transformation!
         //
-	if (!isa<PHINode>(Succ->front()) ||
-            !PropogatePredecessorsForPHIs(BB, Succ)) {
-
+	if (!PropogatePredecessorsForPHIs(BB, Succ)) {
           //cerr << "Killing Trivial BB: \n" << BB;
-
           BB->replaceAllUsesWith(Succ);
           std::string OldName = BB->getName();
 





More information about the llvm-commits mailing list