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

Chris Lattner lattner at cs.uiuc.edu
Fri Feb 17 16:33:29 PST 2006



Changes in directory llvm/lib/Transforms/Utils:

SimplifyCFG.cpp updated: 1.94 -> 1.95
---
Log message:

Fix Transforms/SimplifyCFG/2006-02-17-InfiniteUnroll.ll


---
Diffs of the changes:  (+8 -2)

 SimplifyCFG.cpp |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)


Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.94 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.95
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.94	Sun Jan 22 16:53:01 2006
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp	Fri Feb 17 18:33:17 2006
@@ -1426,8 +1426,8 @@
                   PBI->setSuccessor(1, OldTrue);
                 }
 
-                if (PBI->getSuccessor(0) == TrueDest ||
-                    PBI->getSuccessor(1) == FalseDest) {
+                if ((PBI->getSuccessor(0) == TrueDest && FalseDest != BB) ||
+                    (PBI->getSuccessor(1) == FalseDest && TrueDest != BB)) {
                   // Clone Cond into the predecessor basic block, and or/and the
                   // two conditions together.
                   Instruction *New = Cond->clone();
@@ -1512,6 +1512,12 @@
                 PBIOp = BIOp = -1;
               }
               
+              // Check to make sure that the other destination of this branch
+              // isn't BB itself.  If so, this is an infinite loop that will
+              // keep getting unwound.
+              if (PBIOp != -1 && PBI->getSuccessor(PBIOp) == BB)
+                PBIOp = BIOp = -1;
+              
               // Finally, if everything is ok, fold the branches to logical ops.
               if (PBIOp != -1) {
                 BasicBlock *CommonDest = PBI->getSuccessor(PBIOp);






More information about the llvm-commits mailing list