[PATCH] D153154: [Inliner]Use a hybrid of cost-benefit and cost-threshold analysis.
Mingming Liu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 16 09:58:35 PDT 2023
mingmingl created this revision.
Herald added subscribers: ChuanqiXu, haicheng, hiraditya.
Herald added a project: All.
mingmingl requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
(WIP) The threshold should be a target-specific number.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153154
Files:
llvm/lib/Analysis/InlineCost.cpp
Index: llvm/lib/Analysis/InlineCost.cpp
===================================================================
--- llvm/lib/Analysis/InlineCost.cpp
+++ llvm/lib/Analysis/InlineCost.cpp
@@ -88,6 +88,18 @@
"inline-enable-cost-benefit-analysis", cl::Hidden, cl::init(false),
cl::desc("Enable the cost-benefit analysis for the inliner"));
+static cl::opt<bool> EnableHybridAnalysis(
+ "inline-hybrid-analysis", cl::init(false), cl::Hidden,
+ cl::desc("If set to true, a hybrid of cost-benefit analysis and "
+ "cost-threshold analysis is used. In parctice, a hybrid model "
+ "should be used when machine-functions-splitter is not enabled."));
+
+static cl::opt<int> AggressiveInlineSavingsMultiplier(
+ "aggressive-inline-savings-multiplier", cl::Hidden, cl::init(3),
+ cl::desc("The multiplier to multiply cycle savings. If a callee's cycle "
+ "saving is greater than cost using this multiplier, it's a "
+ "stronger signal that inlining this callee is useful"));
+
static cl::opt<int> InlineSavingsMultiplier(
"inline-savings-multiplier", cl::Hidden, cl::init(8),
cl::desc("Multiplier to multiply cycle savings by during inlining"));
@@ -898,10 +910,19 @@
// Note that the left hand side is specific to a call site. The right hand
// side is a constant for the entire executable.
APInt LHS = CycleSavings;
- LHS *= InlineSavingsMultiplier;
+ LHS *= AggressiveInlineSavingsMultiplier;
APInt RHS(128, PSI->getOrCompHotCountThreshold());
RHS *= Size;
- return LHS.uge(RHS);
+ if (LHS.uge(RHS))
+ return true;
+
+ APInt ConservativeLHS = CycleSavings;
+ ConservativeLHS *= InlineSavingsMultiplier;
+
+ if (!ConservativeLHS.uge(RHS))
+ return false;
+
+ return std::nullopt;
}
InlineResult finalizeAnalysis() override {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153154.532208.patch
Type: text/x-patch
Size: 1863 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230616/39eaa6f4/attachment.bin>
More information about the llvm-commits
mailing list