[PATCH] D98577: [InlineCost] Compute the savings of switch statements and SROA in the cost benefit analysis
Liqiang Tao via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 13 03:20:55 PST 2021
taolq created this revision.
Herald added subscribers: haicheng, hiraditya, eraman.
taolq requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D98577
Files:
llvm/lib/Analysis/InlineCost.cpp
Index: llvm/lib/Analysis/InlineCost.cpp
===================================================================
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -743,14 +743,21 @@
SimplifiedValues.lookup(BI->getCondition()))) {
CurrentSavings += InlineConstants::InstrCost;
}
+ } else if (SwitchInst *SI = dyn_cast<SwitchInst>(&I)) {
+ // Count a switch statement as savings if we can fold it.
+ if (dyn_cast_or_null<ConstantInt>(
+ SimplifiedValues.lookup(SI->getCondition()))) {
+ CurrentSavings += InlineConstants::InstrCost;
+ }
} else if (Value *V = dyn_cast<Value>(&I)) {
- // Count an instruction as savings if we can fold it.
- if (SimplifiedValues.count(V)) {
+ // Count an instruction as savings if we can fold it
+ // or it could be simplified through SROA.
+ if (SimplifiedValues.count(V) || SROAArgValues.count(V)) {
CurrentSavings += InlineConstants::InstrCost;
}
}
- // TODO: Consider other forms of savings like switch statements,
- // indirect calls becoming direct, SROACostSavings, LoadEliminationCost,
+ // TODO: Consider other forms of savings like
+ // indirect calls becoming direct, LoadEliminationCost,
// etc.
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98577.330439.patch
Type: text/x-patch
Size: 1400 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210313/35df619b/attachment.bin>
More information about the llvm-commits
mailing list