[llvm-commits] CVS: llvm/lib/Transforms/Utils/Local.cpp
Chris Lattner
lattner at cs.uiuc.edu
Sat Aug 23 18:25:17 PDT 2003
Changes in directory llvm/lib/Transforms/Utils:
Local.cpp updated: 1.9 -> 1.10
---
Log message:
Implement SimplifyCFG/2003-08-17-FoldSwitch.ll:test5
---
Diffs of the changes:
Index: llvm/lib/Transforms/Utils/Local.cpp
diff -u llvm/lib/Transforms/Utils/Local.cpp:1.9 llvm/lib/Transforms/Utils/Local.cpp:1.10
--- llvm/lib/Transforms/Utils/Local.cpp:1.9 Sun Aug 17 15:21:14 2003
+++ llvm/lib/Transforms/Utils/Local.cpp Sat Aug 23 18:18:19 2003
@@ -80,6 +80,9 @@
// single branch instruction!
ConstantInt *CI = dyn_cast<ConstantInt>(SI->getCondition());
BasicBlock *TheOnlyDest = SI->getSuccessor(0); // The default dest
+ BasicBlock *DefaultDest = TheOnlyDest;
+ assert(TheOnlyDest == SI->getDefaultDest() &&
+ "Default destination is not successor #0?");
// Figure out which case it goes to...
for (unsigned i = 1, e = SI->getNumSuccessors(); i != e; ++i) {
@@ -87,6 +90,16 @@
if (SI->getSuccessorValue(i) == CI) {
TheOnlyDest = SI->getSuccessor(i);
break;
+ }
+
+ // Check to see if this branch is going to the same place as the default
+ // dest. If so, eliminate it as an explicit compare.
+ if (SI->getSuccessor(i) == DefaultDest) {
+ // Remove this entry...
+ DefaultDest->removePredecessor(SI->getParent());
+ SI->removeCase(i);
+ --i; --e; // Don't skip an entry...
+ continue;
}
// Otherwise, check to see if the switch only branches to one destination.
More information about the llvm-commits
mailing list