diff --git a/llvm/lib/Passes/PassBuilder.cpp b/llvm/lib/Passes/PassBuilder.cpp --- a/llvm/lib/Passes/PassBuilder.cpp +++ b/llvm/lib/Passes/PassBuilder.cpp @@ -301,6 +301,7 @@ extern cl::opt EnableIROutliner; extern cl::opt EnableOrderFileInstrumentation; extern cl::opt EnableCHR; +extern cl::opt EnableLoopInterchange; extern cl::opt EnableUnrollAndJam; extern cl::opt EnableLoopFlatten; extern cl::opt RunNewGVN; @@ -582,6 +583,10 @@ C(LPM2, Level); LPM2.addPass(LoopDeletionPass()); + + if (EnableLoopInterchange) + LPM2.addPass(LoopInterchangePass()); + // 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 @@ -748,6 +753,10 @@ C(LPM2, Level); LPM2.addPass(LoopDeletionPass()); + + if (EnableLoopInterchange) + LPM2.addPass(LoopInterchangePass()); + // 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 diff --git a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp --- a/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/llvm/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -84,9 +84,9 @@ clEnumValN(::CFLAAType::Both, "both", "Enable both variants of CFL-AA"))); -static cl::opt EnableLoopInterchange( +cl::opt EnableLoopInterchange( "enable-loopinterchange", cl::init(false), cl::Hidden, - cl::desc("Enable the new, experimental LoopInterchange Pass")); + cl::desc("Enable the experimental LoopInterchange Pass")); cl::opt EnableUnrollAndJam("enable-unroll-and-jam", cl::init(false), cl::Hidden,