diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -855,6 +855,9 @@ SimplifiedValues.lookup(BI->getCondition()))) { CurrentSavings += InstrCost; } + } else if (SwitchInst *SI = dyn_cast(&I)) { + if (isa_and_present(SimplifiedValues.lookup(SI->getCondition()))) + CurrentSavings += InstrCost; } else if (Value *V = dyn_cast(&I)) { // Count an instruction as savings if we can fold it. if (SimplifiedValues.count(V)) {