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

Chris Lattner lattner at cs.uiuc.edu
Tue Mar 16 13:46:01 PST 2004


Changes in directory llvm/lib/Transforms/Utils:

SimplifyCFG.cpp updated: 1.29 -> 1.30

---
Log message:

Do not copy gigantic switch instructions


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

Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
diff -u llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.29 llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.30
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp:1.29	Sat Feb 28 15:28:10 2004
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp	Tue Mar 16 13:45:07 2004
@@ -331,8 +331,15 @@
 // isValueEqualityComparison - Return true if the specified terminator checks to
 // see if a value is equal to constant integer value.
 static Value *isValueEqualityComparison(TerminatorInst *TI) {
-  if (SwitchInst *SI = dyn_cast<SwitchInst>(TI))
+  if (SwitchInst *SI = dyn_cast<SwitchInst>(TI)) {
+    // Do not permit merging of large switch instructions into their
+    // predecessors unless there is only one predecessor.
+    if (SI->getNumSuccessors() * std::distance(pred_begin(SI->getParent()),
+                                               pred_end(SI->getParent())) > 128)
+      return 0;
+
     return SI->getCondition();
+  }
   if (BranchInst *BI = dyn_cast<BranchInst>(TI))
     if (BI->isConditional() && BI->getCondition()->hasOneUse())
       if (SetCondInst *SCI = dyn_cast<SetCondInst>(BI->getCondition()))





More information about the llvm-commits mailing list