[llvm-commits] CVS: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp

Nick Lewycky nicholas at mxc.ca
Tue Oct 3 10:19:25 CDT 2006



Changes in directory llvm/lib/Transforms/Scalar:

PredicateSimplifier.cpp updated: 1.17 -> 1.18
---
Log message:

Simplify, now that predsimplify depends on break-crit-edges.
Fix SwitchInst where dest-block is the same as one of the cases.


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

 PredicateSimplifier.cpp |   34 ++++++++--------------------------
 1 files changed, 8 insertions(+), 26 deletions(-)


Index: llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp
diff -u llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.17 llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.18
--- llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp:1.17	Tue Oct  3 09:52:23 2006
+++ llvm/lib/Transforms/Scalar/PredicateSimplifier.cpp	Tue Oct  3 10:19:11 2006
@@ -413,8 +413,6 @@
     // Used by terminator instructions to proceed from the current basic
     // block to the next. Verifies that "current" dominates "next",
     // then calls visitBasicBlock.
-    void proceedToSuccessor(TerminatorInst *TI, unsigned edge,
-                            PropertySet &CurrentPS, PropertySet &NextPS);
     void proceedToSuccessors(PropertySet &CurrentPS, BasicBlock *Current);
 
     // Visits each instruction in the basic block.
@@ -616,17 +614,6 @@
     visit(BO, KnownProperties);
 }
 
-// The basic block on the target of the specified edge must be known
-// to be immediately dominated by the parent of the TerminatorInst.
-void PredicateSimplifier::proceedToSuccessor(TerminatorInst *TI,
-                                             unsigned edge,
-                                             PropertySet &CurrentPS,
-                                             PropertySet &NextPS) {
-  assert(edge < TI->getNumSuccessors() && "Invalid index for edge.");
-
-  visitBasicBlock(TI->getSuccessor(edge), NextPS);
-}
-
 void PredicateSimplifier::proceedToSuccessors(PropertySet &KP,
                                               BasicBlock *BBCurrent) {
   DTNodeType *Current = DT->getNode(BBCurrent);
@@ -676,14 +663,14 @@
     if ((*I)->getBlock() == TrueDest) {
       PropertySet TrueProperties(KP);
       TrueProperties.addEqual(ConstantBool::getTrue(), Condition);
-      proceedToSuccessor(BI, 0, KP, TrueProperties);
+      visitBasicBlock(TrueDest, TrueProperties);
       continue;
     }
 
     if ((*I)->getBlock() == FalseDest) {
       PropertySet FalseProperties(KP);
       FalseProperties.addEqual(ConstantBool::getFalse(), Condition);
-      proceedToSuccessor(BI, 1, KP, FalseProperties);
+      visitBasicBlock(FalseDest, FalseProperties);
       continue;
     }
 
@@ -702,20 +689,15 @@
   for (DTNodeType::iterator I = Node->begin(), E = Node->end(); I != E; ++I) {
     BasicBlock *BB = (*I)->getBlock();
 
-    PropertySet Copy(KP);
-
+    PropertySet BBProperties(KP);
     if (BB == SI->getDefaultDest()) {
-      PropertySet NewProperties(KP);
       for (unsigned i = 1, e = SI->getNumCases(); i < e; ++i)
-        NewProperties.addNotEqual(Condition, SI->getCaseValue(i));
-
-      proceedToSuccessor(SI, 0, Copy, NewProperties);
+        if (SI->getSuccessor(i) != BB)
+          BBProperties.addNotEqual(Condition, SI->getCaseValue(i));
     } else if (ConstantInt *CI = SI->findCaseDest(BB)) {
-      PropertySet NewProperties(KP);
-      NewProperties.addEqual(Condition, CI);
-      proceedToSuccessor(SI, SI->findCaseValue(CI), Copy, NewProperties);
-    } else 
-      visitBasicBlock(BB, Copy);
+      BBProperties.addEqual(Condition, CI);
+    }
+    visitBasicBlock(BB, BBProperties);
   }
 }
 






More information about the llvm-commits mailing list