[InlineCost]Account for switch instructons when the switch condition could be simplified as a result of inlines.

Reviewed By: kazu

Differential Revision: https://reviews.llvm.org/D152053
This commit is contained in:
Mingming Liu 2023-06-02 21:33:07 -07:00
parent 9ee65a7618
commit 2639fdc5dd

View File

@ -855,6 +855,9 @@ class InlineCostCallAnalyzer final : public CallAnalyzer {
SimplifiedValues.lookup(BI->getCondition()))) {
CurrentSavings += InstrCost;
}
} else if (SwitchInst *SI = dyn_cast<SwitchInst>(&I)) {
if (isa_and_present<ConstantInt>(SimplifiedValues.lookup(SI->getCondition())))
CurrentSavings += InstrCost;
} else if (Value *V = dyn_cast<Value>(&I)) {
// Count an instruction as savings if we can fold it.
if (SimplifiedValues.count(V)) {