diff --git a/lib/Transforms/Utils/Local.cpp b/lib/Transforms/Utils/Local.cpp index d3778c50443..3ea76c4ea51 100644 --- a/lib/Transforms/Utils/Local.cpp +++ b/lib/Transforms/Utils/Local.cpp @@ -74,6 +74,12 @@ bool ConstantFoldTerminator(BasicBlock *BB) { BI->setUnconditionalDest(Dest1); return true; } + } else if (SwitchInst *SI = dyn_cast(TI)) { + if (ConstantInt *CI = dyn_cast(SI->getCondition())) { + + + } + } return false; } diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 1adbef9253a..ed0d45be26b 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -121,6 +121,10 @@ bool SimplifyCFG(BasicBlock *BB) { return true; } + // Check to see if we can constant propagate this terminator instruction + // away... + bool Changed = ConstantFoldTerminator(BB); + // Check to see if this block has no non-phi instructions and only a single // successor. If so, replace references to this basic block with references // to the successor. @@ -251,5 +255,5 @@ bool SimplifyCFG(BasicBlock *BB) { } } - return false; + return Changed; }