Revert "[LoopFlatten] Move it to a LoopPassManager"

This commit caused performance regressions due to differences in the
expected code during loop flattening. Reverting it until the fix is
ready, which hopefully wont take too long.

This reverts commit 86825fc2fb.
This commit is contained in:
David Green 2022-01-10 11:03:49 +00:00
parent 33cec20dbd
commit e92d63b467
1 changed files with 7 additions and 6 deletions

View File

@ -311,8 +311,6 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
if (EnableLoopInterchange)
LPM2.addPass(LoopInterchangePass());
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
@ -337,6 +335,8 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
/*UseBlockFrequencyInfo=*/true));
FPM.addPass(SimplifyCFGPass());
FPM.addPass(InstCombinePass());
if (EnableLoopFlatten)
FPM.addPass(createFunctionToLoopPassAdaptor(LoopFlattenPass()));
// The loop passes in LPM2 (LoopFullUnrollPass) do not preserve MemorySSA.
// *All* loop passes must preserve it, in order to be able to use it.
FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM2),
@ -485,8 +485,6 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
if (EnableLoopInterchange)
LPM2.addPass(LoopInterchangePass());
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
@ -511,6 +509,8 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
/*UseBlockFrequencyInfo=*/true));
FPM.addPass(SimplifyCFGPass());
FPM.addPass(InstCombinePass());
if (EnableLoopFlatten)
FPM.addPass(createFunctionToLoopPassAdaptor(LoopFlattenPass()));
// The loop passes in LPM2 (LoopIdiomRecognizePass, IndVarSimplifyPass,
// LoopDeletionPass and LoopFullUnrollPass) do not preserve MemorySSA.
// *All* loop passes must preserve it, in order to be able to use it.
@ -1623,6 +1623,9 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
MainFPM.addPass(DSEPass());
MainFPM.addPass(MergedLoadStoreMotionPass());
// More loops are countable; try to optimize them.
if (EnableLoopFlatten && Level.getSpeedupLevel() > 1)
MainFPM.addPass(createFunctionToLoopPassAdaptor(LoopFlattenPass()));
if (EnableConstraintElimination)
MainFPM.addPass(ConstraintEliminationPass());
@ -1630,8 +1633,6 @@ PassBuilder::buildLTODefaultPipeline(OptimizationLevel Level,
LoopPassManager LPM;
LPM.addPass(IndVarSimplifyPass());
LPM.addPass(LoopDeletionPass());
if (EnableLoopFlatten && Level.getSpeedupLevel() > 1)
LPM.addPass(LoopFlattenPass());
// FIXME: Add loop interchange.
// Unroll small loops and perform peeling.