From 87e3ae17fd3fe5d83fbed348dcc235863c143327 Mon Sep 17 00:00:00 2001 From: Ta-Wei Tu Date: Sun, 7 Mar 2021 02:37:54 +0800 Subject: [PATCH] [NPM] Add -enable-loopinterchange option to NPM We have the `enable-loopinterchange` option in legacy pass manager but not in NPM. Add `LoopInterchange` pass to the optimization pipeline (at the same position as before) when `enable-loopinterchange` is turned on. Reviewed By: aeubanks, fhahn Differential Revision: https://reviews.llvm.org/D98116 --- lib/Passes/PassBuilder.cpp | 9 +++++++++ lib/Transforms/IPO/PassManagerBuilder.cpp | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/lib/Passes/PassBuilder.cpp b/lib/Passes/PassBuilder.cpp index 52f7026c40e..12ed8ee8b05 100644 --- a/lib/Passes/PassBuilder.cpp +++ b/lib/Passes/PassBuilder.cpp @@ -301,6 +301,7 @@ extern cl::opt EnableHotColdSplit; 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 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level, 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 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level, 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/lib/Transforms/IPO/PassManagerBuilder.cpp b/lib/Transforms/IPO/PassManagerBuilder.cpp index 3b495dd71c2..109e7c97ff1 100644 --- a/lib/Transforms/IPO/PassManagerBuilder.cpp +++ b/lib/Transforms/IPO/PassManagerBuilder.cpp @@ -84,9 +84,9 @@ static cl::opt<::CFLAAType> 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,