This is an archive of the discontinued LLVM Phabricator instance.

[NewPM][Hexagon] Fix HexagonVectorLoopCarriedReusePass position in pipeline
ClosedPublic

Authored by aeubanks on Dec 29 2020, 8:03 PM.

Details

Summary

In https://reviews.llvm.org/D88138 this was incorrectly added with
registerOptimizerLastEPCallback(), when it should be
registerLoopOptimizerEndEPCallback(), matching the legacy PM's
EP_LoopOptimizerEnd.

Diff Detail

Event Timeline

aeubanks created this revision.Dec 29 2020, 8:03 PM
aeubanks requested review of this revision.Dec 29 2020, 8:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 29 2020, 8:03 PM
aeubanks added a reviewer: rnk.Jan 7 2021, 2:22 PM
aeubanks added a reviewer: asbirlea.
rnk accepted this revision.Jan 7 2021, 2:26 PM

lgtm

llvm/lib/Target/Hexagon/HexagonTargetMachine.cpp
278

Yep.

This revision is now accepted and ready to land.Jan 7 2021, 2:26 PM

@asbirlea I remember that HexagonVLCR pass has a dependency on LCSSA and LoopSimplifyPass. Is there any way we can run these passes too at LoopOptimizerEndEP? If not maybe use another EP for legacy PM? I'm not sure if the below code would run these passes in the correct order as well

PB.registerOptimizerLastEPCallback(
    [=](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
      LoopPassManager LPM(DebugPassManager);
      FunctionPassManager FPM(DebugPassManager);
      LPM.addPass(HexagonVectorLoopCarriedReusePass());
      FPM.addPass(LoopSimplifyPass());
      FPM.addPass(LCSSAPass());
      FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM)));
      MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
    });

@pranavb Can you comment more on this?

@asbirlea I remember that HexagonVLCR pass has a dependency on LCSSA and LoopSimplifyPass. Is there any way we can run these passes too at LoopOptimizerEndEP? If not maybe use another EP for legacy PM? I'm not sure if the below code would run these passes in the correct order as well

PB.registerOptimizerLastEPCallback(
    [=](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
      LoopPassManager LPM(DebugPassManager);
      FunctionPassManager FPM(DebugPassManager);
      LPM.addPass(HexagonVectorLoopCarriedReusePass());
      FPM.addPass(LoopSimplifyPass());
      FPM.addPass(LCSSAPass());
      FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM)));
      MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
    });

@pranavb Can you comment more on this?

LCSSA should be preserved by all loop passes under the new PM. LCSSA and LoopSimplify are run before any loop pass: https://github.com/llvm/llvm-project/blob/8dddcc762dd98d53b9406b36e92f62502834187c/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h#L406. Although I don't think passes are required preserve loop simplify form.

quic_aankit added a comment.EditedJan 7 2021, 4:55 PM

@asbirlea I remember that HexagonVLCR pass has a dependency on LCSSA and LoopSimplifyPass. Is there any way we can run these passes too at LoopOptimizerEndEP? If not maybe use another EP for legacy PM? I'm not sure if the below code would run these passes in the correct order as well

PB.registerOptimizerLastEPCallback(
    [=](ModulePassManager &MPM, PassBuilder::OptimizationLevel Level) {
      LoopPassManager LPM(DebugPassManager);
      FunctionPassManager FPM(DebugPassManager);
      LPM.addPass(HexagonVectorLoopCarriedReusePass());
      FPM.addPass(LoopSimplifyPass());
      FPM.addPass(LCSSAPass());
      FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM)));
      MPM.addPass(createModuleToFunctionPassAdaptor(std::move(FPM)));
    });

@pranavb Can you comment more on this?

LCSSA should be preserved by all loop passes under the new PM. LCSSA and LoopSimplify are run before any loop pass: https://github.com/llvm/llvm-project/blob/8dddcc762dd98d53b9406b36e92f62502834187c/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h#L406. Although I don't think passes are required preserve loop simplify form.

Got it. In that case, the patch looks good to me. Thanks!