|
105 | 105 | #include "llvm/Transforms/Scalar/LoopSink.h"
|
106 | 106 | #include "llvm/Transforms/Scalar/LoopUnrollAndJamPass.h"
|
107 | 107 | #include "llvm/Transforms/Scalar/LoopUnrollPass.h"
|
| 108 | +#include "llvm/Transforms/Scalar/LoopVersioningLICM.h" |
108 | 109 | #include "llvm/Transforms/Scalar/LowerConstantIntrinsics.h"
|
109 | 110 | #include "llvm/Transforms/Scalar/LowerExpectIntrinsic.h"
|
110 | 111 | #include "llvm/Transforms/Scalar/LowerMatrixIntrinsics.h"
|
@@ -271,6 +272,10 @@ static cl::opt<AttributorRunOption> AttributorRun(
|
271 | 272 | clEnumValN(AttributorRunOption::NONE, "none",
|
272 | 273 | "disable attributor runs")));
|
273 | 274 |
|
| 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 | + |
274 | 279 | cl::opt<bool> EnableMemProfContextDisambiguation(
|
275 | 280 | "enable-memprof-context-disambiguation", cl::init(false), cl::Hidden,
|
276 | 281 | cl::ZeroOrMore, cl::desc("Enable MemProf context disambiguation"));
|
@@ -1343,6 +1348,21 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
|
1343 | 1348 | invokeOptimizerEarlyEPCallbacks(MPM, Level);
|
1344 | 1349 |
|
1345 | 1350 | 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 | + |
1346 | 1366 | OptimizePM.addPass(Float2IntPass());
|
1347 | 1367 | OptimizePM.addPass(LowerConstantIntrinsicsPass());
|
1348 | 1368 |
|
|
0 commit comments