summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pass.h5
-rw-r--r--src/passes/Inlining.cpp3
-rw-r--r--src/tools/optimization-options.h10
3 files changed, 16 insertions, 2 deletions
diff --git a/src/pass.h b/src/pass.h
index 802a34ab5..2bb34aeea 100644
--- a/src/pass.h
+++ b/src/pass.h
@@ -82,6 +82,11 @@ struct InliningOptions {
// Loops usually mean the function does heavy work, so the call overhead
// is not significant and we do not inline such functions by default.
bool allowFunctionsWithLoops = false;
+ // The number of ifs to allow partial inlining of their conditions. A value of
+ // zero disables partial inlining.
+ // TODO: Investigate enabling this. Locally 4 appears useful on real-world
+ // code, but reports of regressions have arrived.
+ Index partialInliningIfs = 0;
};
struct PassOptions {
diff --git a/src/passes/Inlining.cpp b/src/passes/Inlining.cpp
index e1ae4c2a8..7467d2559 100644
--- a/src/passes/Inlining.cpp
+++ b/src/passes/Inlining.cpp
@@ -641,8 +641,7 @@ private:
// without an else.
// Find the number of ifs.
- // TODO: Investigate more values here. 4 appears useful on real-world code.
- const Index MaxIfs = 4;
+ const Index MaxIfs = options.inlining.partialInliningIfs;
Index numIfs = 0;
while (getIf(body, numIfs) && numIfs <= MaxIfs) {
numIfs++;
diff --git a/src/tools/optimization-options.h b/src/tools/optimization-options.h
index 58a8e3980..8d526f92f 100644
--- a/src/tools/optimization-options.h
+++ b/src/tools/optimization-options.h
@@ -171,6 +171,16 @@ struct OptimizationOptions : public ToolOptions {
[this](Options* o, const std::string&) {
passOptions.inlining.allowFunctionsWithLoops = true;
})
+ .add("--partial-inlining-ifs",
+ "-pii",
+ "Number of ifs allowed in partial inlining (zero means partial "
+ "inlining is disabled) (default: " +
+ std::to_string(InliningOptions().partialInliningIfs) + ')',
+ Options::Arguments::One,
+ [this](Options* o, const std::string& argument) {
+ passOptions.inlining.partialInliningIfs =
+ static_cast<Index>(std::stoi(argument));
+ })
.add("--ignore-implicit-traps",
"-iit",
"Optimize under the helpful assumption that no surprising traps "