Skip to content

Commit cba73f8

Browse files
committed
[Passes] Move LoopInterchange into optimization pipeline
As mentioned in llvm#145071, LoopInterchange should be part of the optimization pipeline rather than the simplification pipeline. This patch moves LoopInterchange into the optimization pipeline. More contexts: - By default, LoopInterchange attempts to improve data locality, however, it also takes vectorization opportunities into account. Given that, it is reasonable to run it as close to vectorization as possible. - I looked into previous changes related to the placement of LoopInterchange, but couldn’t find any strong motivation suggesting that it benefits other simplifications. - As far as I tried some tests (including llvm-test-suite), removing LoopInterchange from the simplification pipeline does not affect other simplifications. Therefore, there doesn't seem to be much value in keeping it there.
1 parent 8d9911e commit cba73f8

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -690,9 +690,6 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
690690

691691
LPM2.addPass(LoopDeletionPass());
692692

693-
if (PTO.LoopInterchange)
694-
LPM2.addPass(LoopInterchangePass());
695-
696693
// Do not enable unrolling in PreLinkThinLTO phase during sample PGO
697694
// because it changes IR to makes profile annotation in back compile
698695
// inaccurate. The normal unroller doesn't pay attention to forced full unroll
@@ -1547,6 +1544,10 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
15471544
// this may need to be revisited once we run GVN before loop deletion
15481545
// in the simplification pipeline.
15491546
LPM.addPass(LoopDeletionPass());
1547+
1548+
if (PTO.LoopInterchange)
1549+
LPM.addPass(LoopInterchangePass());
1550+
15501551
OptimizePM.addPass(createFunctionToLoopPassAdaptor(
15511552
std::move(LPM), /*UseMemorySSA=*/false, /*UseBlockFrequencyInfo=*/false));
15521553

0 commit comments

Comments
 (0)