[PATCH] D148343: [Pipelines] Add LoopSink and DivRemPairs to LTO post-link pipeline
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 14 07:38:51 PDT 2023
nikic created this revision.
nikic added reviewers: aeubanks, fhahn, dmgreen.
Herald added subscribers: wlei, ormris, StephenFan, wenlei, steven_wu, hiraditya, inglorion.
Herald added a project: All.
nikic requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
As pointed out in D148010 <https://reviews.llvm.org/D148010>, these passes are missing from the LTO post-link pipeline. They are present in the pre-link pipeline, but LoopSink is completely useless there (it will always be fully undone by LICM post-link) and DivRemPairs is mostly useless (I believe most of what it does will be undone by InstCombine).
I've not added RelLookupTableConverterPass, because it's also disabled in the LTO pre-link pipeline, with a comment that there is an unresolved issue with full LTO.
Compile-time impact of the extra passes is minimal: http://llvm-compile-time-tracker.com/compare.php?from=09ba7b605327812cfcec4f3c01d7fc232dee651d&to=52d546b4fe89ad66011ca9e3a8f2f6dfe4b4ac2f&stat=instructions:u Of course, LoopSink will have a larger impact in PGO builds.
https://reviews.llvm.org/D148343
Files:
llvm/lib/Passes/PassBuilderPipelines.cpp
llvm/test/Other/new-pm-lto-defaults.ll
Index: llvm/test/Other/new-pm-lto-defaults.ll
===================================================================
--- llvm/test/Other/new-pm-lto-defaults.ll
+++ llvm/test/Other/new-pm-lto-defaults.ll
@@ -135,6 +135,8 @@
; CHECK-O23SZ-NEXT: Running pass: JumpThreadingPass on foo
; CHECK-O23SZ-NEXT: Running pass: LowerTypeTestsPass
; CHECK-O-NEXT: Running pass: LowerTypeTestsPass
+; CHECK-O23SZ-NEXT: Running pass: LoopSink
+; CHECK-O23SZ-NEXT: Running pass: DivRemPairs
; CHECK-O23SZ-NEXT: Running pass: SimplifyCFGPass
; CHECK-O23SZ-NEXT: Running pass: EliminateAvailableExternallyPass
; CHECK-O23SZ-NEXT: Running pass: GlobalDCEPass
Index: llvm/lib/Passes/PassBuilderPipelines.cpp
===================================================================
--- llvm/lib/Passes/PassBuilderPipelines.cpp
+++ llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -1838,10 +1838,24 @@
MPM.addPass(HotColdSplittingPass());
// Add late LTO optimization passes.
+ FunctionPassManager LateFPM;
+
+ // LoopSink pass sinks instructions hoisted by LICM, which serves as a
+ // canonicalization pass that enables other optimizations. As a result,
+ // LoopSink pass needs to be a very late IR pass to avoid undoing LICM
+ // result too early.
+ LateFPM.addPass(LoopSinkPass());
+
+ // This hoists/decomposes div/rem ops. It should run after other sink/hoist
+ // passes to avoid re-sinking, but before SimplifyCFG because it can allow
+ // flattening of blocks.
+ LateFPM.addPass(DivRemPairsPass());
+
// Delete basic blocks, which optimization passes may have killed.
- MPM.addPass(createModuleToFunctionPassAdaptor(SimplifyCFGPass(
+ LateFPM.addPass(SimplifyCFGPass(
SimplifyCFGOptions().convertSwitchRangeToICmp(true).hoistCommonInsts(
- true))));
+ true)));
+ MPM.addPass(createModuleToFunctionPassAdaptor(std::move(LateFPM)));
// Drop bodies of available eternally objects to improve GlobalDCE.
MPM.addPass(EliminateAvailableExternallyPass());
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D148343.513588.patch
Type: text/x-patch
Size: 1988 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230414/2c97f4cc/attachment.bin>
More information about the llvm-commits
mailing list