1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00

[LoopFlatten] Run it earlier, just before IndVarSimplify

This is a prep step for widening induction variables in LoopFlatten if this is
posssible (D90640), 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.

Differential Revision: https://reviews.llvm.org/D90402
This commit is contained in:
Sjoerd Meijer 2020-11-09 16:16:54 +00:00
parent 79d4f8d97b
commit 2b47fb5801
2 changed files with 9 additions and 8 deletions

View File

@ -535,6 +535,9 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
// TODO: Investigate promotion cap for O1. // TODO: Investigate promotion cap for O1.
LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap)); LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap));
LPM1.addPass(SimpleLoopUnswitchPass()); LPM1.addPass(SimpleLoopUnswitchPass());
if (EnableLoopFlatten)
FPM.addPass(LoopFlattenPass());
LPM2.addPass(IndVarSimplifyPass()); LPM2.addPass(IndVarSimplifyPass());
LPM2.addPass(LoopIdiomRecognizePass()); LPM2.addPass(LoopIdiomRecognizePass());
@ -542,8 +545,6 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
C(LPM2, Level); C(LPM2, Level);
LPM2.addPass(LoopDeletionPass()); LPM2.addPass(LoopDeletionPass());
if (EnableLoopFlatten)
FPM.addPass(LoopFlattenPass());
// Do not enable unrolling in PreLinkThinLTO phase during sample PGO // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
// because it changes IR to makes profile annotation in back compile // because it changes IR to makes profile annotation in back compile
// inaccurate. The normal unroller doesn't pay attention to forced full unroll // inaccurate. The normal unroller doesn't pay attention to forced full unroll

View File

@ -441,6 +441,10 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
MPM.add(createCFGSimplificationPass()); MPM.add(createCFGSimplificationPass());
MPM.add(createInstructionCombiningPass()); MPM.add(createInstructionCombiningPass());
// We resume loop passes creating a second loop pipeline here. // 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(createIndVarSimplifyPass()); // Canonicalize indvars
MPM.add(createLoopIdiomPass()); // Recognize idioms like memset. MPM.add(createLoopIdiomPass()); // Recognize idioms like memset.
addExtensionsToPM(EP_LateLoopOptimizations, MPM); addExtensionsToPM(EP_LateLoopOptimizations, MPM);
@ -448,10 +452,6 @@ void PassManagerBuilder::addFunctionSimplificationPasses(
if (EnableLoopInterchange) if (EnableLoopInterchange)
MPM.add(createLoopInterchangePass()); // Interchange loops MPM.add(createLoopInterchangePass()); // Interchange loops
if (EnableLoopFlatten) {
MPM.add(createLoopFlattenPass()); // Flatten loops
MPM.add(createLoopSimplifyCFGPass());
}
// Unroll small loops // Unroll small loops
MPM.add(createSimpleLoopUnrollPass(OptLevel, DisableUnrollLoops, MPM.add(createSimpleLoopUnrollPass(OptLevel, DisableUnrollLoops,
@ -1045,12 +1045,12 @@ void PassManagerBuilder::addLTOOptimizationPasses(legacy::PassManagerBase &PM) {
PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds. PM.add(createMergedLoadStoreMotionPass()); // Merge ld/st in diamonds.
// More loops are countable; try to optimize them. // More loops are countable; try to optimize them.
if (EnableLoopFlatten)
PM.add(createLoopFlattenPass());
PM.add(createIndVarSimplifyPass()); PM.add(createIndVarSimplifyPass());
PM.add(createLoopDeletionPass()); PM.add(createLoopDeletionPass());
if (EnableLoopInterchange) if (EnableLoopInterchange)
PM.add(createLoopInterchangePass()); PM.add(createLoopInterchangePass());
if (EnableLoopFlatten)
PM.add(createLoopFlattenPass());
// Unroll small loops // Unroll small loops
PM.add(createSimpleLoopUnrollPass(OptLevel, DisableUnrollLoops, PM.add(createSimpleLoopUnrollPass(OptLevel, DisableUnrollLoops,