Skip to content

Commit f3c417f

Browse files
authored
[Passes] Add option for LoopVersioningLICM pass. (#67107)
User only can use opt to test LoopVersioningLICM pass, and this PR add the option back(deleted in https://reviews.llvm.org/D137915) so that it's easy for verifying if it is useful for some benchmarks.
1 parent 918863d commit f3c417f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@
105105
#include "llvm/Transforms/Scalar/LoopSink.h"
106106
#include "llvm/Transforms/Scalar/LoopUnrollAndJamPass.h"
107107
#include "llvm/Transforms/Scalar/LoopUnrollPass.h"
108+
#include "llvm/Transforms/Scalar/LoopVersioningLICM.h"
108109
#include "llvm/Transforms/Scalar/LowerConstantIntrinsics.h"
109110
#include "llvm/Transforms/Scalar/LowerExpectIntrinsic.h"
110111
#include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
@@ -271,6 +272,10 @@ static cl::opt<AttributorRunOption> AttributorRun(
271272
clEnumValN(AttributorRunOption::NONE, "none",
272273
"disable attributor runs")));
273274

275+
static cl::opt<bool> UseLoopVersioningLICM(
276+
"enable-loop-versioning-licm", cl::init(false), cl::Hidden,
277+
cl::desc("Enable the experimental Loop Versioning LICM pass"));
278+
274279
cl::opt<bool> EnableMemProfContextDisambiguation(
275280
"enable-memprof-context-disambiguation", cl::init(false), cl::Hidden,
276281
cl::ZeroOrMore, cl::desc("Enable MemProf context disambiguation"));
@@ -1343,6 +1348,21 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
13431348
invokeOptimizerEarlyEPCallbacks(MPM, Level);
13441349

13451350
FunctionPassManager OptimizePM;
1351+
// Scheduling LoopVersioningLICM when inlining is over, because after that
1352+
// we may see more accurate aliasing. Reason to run this late is that too
1353+
// early versioning may prevent further inlining due to increase of code
1354+
// size. Other optimizations which runs later might get benefit of no-alias
1355+
// assumption in clone loop.
1356+
if (UseLoopVersioningLICM) {
1357+
OptimizePM.addPass(
1358+
createFunctionToLoopPassAdaptor(LoopVersioningLICMPass()));
1359+
// LoopVersioningLICM pass might increase new LICM opportunities.
1360+
OptimizePM.addPass(createFunctionToLoopPassAdaptor(
1361+
LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
1362+
/*AllowSpeculation=*/true),
1363+
/*USeMemorySSA=*/true, /*UseBlockFrequencyInfo=*/false));
1364+
}
1365+
13461366
OptimizePM.addPass(Float2IntPass());
13471367
OptimizePM.addPass(LowerConstantIntrinsicsPass());
13481368

0 commit comments

Comments
 (0)