-
Notifications
You must be signed in to change notification settings - Fork 101
[Pipelines] Additional unrolling in LTO #536
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| -flto=full \ | ||
| -fvirtual-function-elimination \ | ||
| -fwhole-program-vtables | ||
| -fwhole-program-vtables \ | ||
| -mllvm -extra-LTO-loop-unroll=true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| Additional optimization flags | ||
| ============================= | ||
|
|
||
| ## Additional loop unroll in the LTO pipeline | ||
| In some cases it is benefitial to perform an additional loop unroll pass so that extra information becomes available to later passes, e.g. SROA. | ||
| Use cases where this could be beneficial - multiple (N>=4) nested loops. | ||
|
|
||
| ### Usage: | ||
| -mllvm -extra-LTO-loop-unroll=true/false |
55 changes: 55 additions & 0 deletions
55
patches/llvm-project-perf/0000-LTOpasses-add-loop-unroll.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| From 4adfc5231d2c0182d6278b4aa75eec57648e5dd4 Mon Sep 17 00:00:00 2001 | ||
| From: Vladi Krapp <[email protected]> | ||
| Date: Tue, 3 Sep 2024 14:12:48 +0100 | ||
| Subject: [Pipelines] Additional unrolling in LTO | ||
|
|
||
| Some workloads require specific sequences of events to happen | ||
| to fully simplify. This adds an extra full unrolling pass to help these | ||
| cases on the cores with branch predictors. It helps produce simplified | ||
| loops, which can then be SROA'd allowing further simplification, which | ||
| can be important for performance. | ||
| This is added under own flag - spending extra compile time to get extra | ||
| performance on specific user request. | ||
VladiKrapp-Arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| Originally patch by David Green ([email protected]) | ||
VladiKrapp-Arm marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| --- | ||
| llvm/lib/Passes/PassBuilderPipelines.cpp | 16 ++++++++++++++++ | ||
| 1 file changed, 16 insertions(+) | ||
|
|
||
| diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp | ||
| index 1184123c7710..6dc45d85927a 100644 | ||
| --- a/llvm/lib/Passes/PassBuilderPipelines.cpp | ||
| +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp | ||
| @@ -332,6 +332,10 @@ namespace llvm { | ||
| extern cl::opt<unsigned> MaxDevirtIterations; | ||
| } // namespace llvm | ||
|
|
||
| +static cl::opt<bool> LTOExtraLoopUnroll( | ||
| + "extra-LTO-loop-unroll", cl::init(false), cl::Hidden, | ||
| + cl::desc("Perform extra loop unrolling pass to assist SROA")); | ||
| + | ||
| void PassBuilder::invokePeepholeEPCallbacks(FunctionPassManager &FPM, | ||
| OptimizationLevel Level) { | ||
| for (auto &C : PeepholeEPCallbacks) | ||
| @@ -1940,6 +1944,18 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level, | ||
| MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(ArgumentPromotionPass())); | ||
|
|
||
| FunctionPassManager FPM; | ||
| + | ||
| + if (LTOExtraLoopUnroll) { | ||
| + LoopPassManager OmaxLPM; | ||
| + OmaxLPM.addPass(LoopFullUnrollPass(Level.getSpeedupLevel(), | ||
| + /* OnlyWhenForced= */ !PTO.LoopUnrolling, | ||
| + PTO.ForgetAllSCEVInLoopUnroll)); | ||
| + FPM.addPass( | ||
| + createFunctionToLoopPassAdaptor(std::move(OmaxLPM), | ||
| + /*UseMemorySSA=*/false, | ||
| + /*UseBlockFrequencyInfo=*/true)); | ||
| + } | ||
| + | ||
| // The IPO Passes may leave cruft around. Clean up after them. | ||
| FPM.addPass(InstCombinePass()); | ||
| invokePeepholeEPCallbacks(FPM, Level); | ||
| -- | ||
| 2.34.1 | ||
|
|
||
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.