[PATCH] D90402: [LoopFlatten] Run it earlier, just before IndVarSimplify
Sjoerd Meijer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 29 08:40:29 PDT 2020
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: ostannard, dmgreen, sanwou01.
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.
SjoerdMeijer requested review of this revision.
This is a prep step for widening induction variables of a nested loop in LoopFlatten if this is posssible, to avoid having to perform certain overflow checks. Since IndVarSimplify may already widen induction variables, we want to run LoopFlatten just before IndVarSimplify. This is a minor reshuffle as both passes were already close after each other.
This is separated out from D88880 <https://reviews.llvm.org/D88880>, which is about making LoopFlatten triggeron 64-bit targets too and is the motivation of this work.
PS. No pipeline pass manager test were changed, because LoopFlatten isn't enabled by default yet.
https://reviews.llvm.org/D90402
Files:
llvm/lib/Passes/PassBuilder.cpp
llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
===================================================================
--- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -441,6 +441,10 @@
MPM.add(createCFGSimplificationPass());
MPM.add(createInstructionCombiningPass());
// We resume loop passes creating a second loop pipeline here.
+ if (EnableLoopFlatten) {
+ MPM.add(createLoopFlattenPass()); // Flatten loops
+ MPM.add(createLoopSimplifyCFGPass());
+ }
MPM.add(createIndVarSimplifyPass()); // Canonicalize indvars
MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
addExtensionsToPM(EP_LateLoopOptimizations, MPM);
@@ -448,10 +452,6 @@
if (EnableLoopInterchange)
MPM.add(createLoopInterchangePass()); // Interchange loops
- if (EnableLoopFlatten) {
- MPM.add(createLoopFlattenPass()); // Flatten loops
- MPM.add(createLoopSimplifyCFGPass());
- }
// Unroll small loops
MPM.add(createSimpleLoopUnrollPass(OptLevel, DisableUnrollLoops,
@@ -1045,12 +1045,12 @@
PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds.
// More loops are countable; try to optimize them.
+ if (EnableLoopFlatten)
+ PM.add(createLoopFlattenPass());
PM.add(createIndVarSimplifyPass());
PM.add(createLoopDeletionPass());
if (EnableLoopInterchange)
PM.add(createLoopInterchangePass());
- if (EnableLoopFlatten)
- PM.add(createLoopFlattenPass());
// Unroll small loops
PM.add(createSimpleLoopUnrollPass(OptLevel, DisableUnrollLoops,
Index: llvm/lib/Passes/PassBuilder.cpp
===================================================================
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -522,6 +522,10 @@
// TODO: Investigate promotion cap for O1.
LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap));
LPM1.addPass(SimpleLoopUnswitchPass());
+
+ if (EnableLoopFlatten)
+ LPM2.addPass(LoopFlattenPass());
+
LPM2.addPass(IndVarSimplifyPass());
LPM2.addPass(LoopIdiomRecognizePass());
@@ -529,8 +533,6 @@
C(LPM2, Level);
LPM2.addPass(LoopDeletionPass());
- if (EnableLoopFlatten)
- LPM2.addPass(LoopFlattenPass());
// Do not enable unrolling in PreLinkThinLTO phase during sample PGO
// because it changes IR to makes profile annotation in back compile
// inaccurate. The normal unroller doesn't pay attention to forced full unroll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90402.301635.patch
Type: text/x-patch
Size: 2496 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201029/c939b454/attachment-0001.bin>
More information about the llvm-commits
mailing list