|
132 | 132 | #include "llvm/Transforms/Utils/CountVisits.h"
|
133 | 133 | #include "llvm/Transforms/Utils/InjectTLIMappings.h"
|
134 | 134 | #include "llvm/Transforms/Utils/LibCallsShrinkWrap.h"
|
| 135 | +#include "llvm/Transforms/Utils/LoopIterCountAssumptions.h" |
135 | 136 | #include "llvm/Transforms/Utils/Mem2Reg.h"
|
136 | 137 | #include "llvm/Transforms/Utils/MoveAutoInit.h"
|
137 | 138 | #include "llvm/Transforms/Utils/NameAnonGlobals.h"
|
@@ -306,6 +307,11 @@ static cl::opt<bool> UseLoopVersioningLICM(
|
306 | 307 | "enable-loop-versioning-licm", cl::init(false), cl::Hidden,
|
307 | 308 | cl::desc("Enable the experimental Loop Versioning LICM pass"));
|
308 | 309 |
|
| 310 | +static cl::opt<bool> EnableLoopIterCountToAssumptions( |
| 311 | + "enable-loop-iter-count-assumptions", cl::Hidden, cl::init(false), |
| 312 | + cl::desc( |
| 313 | + "Enable Conversion of Loop Iteration Count Metadata to Assumptions.")); |
| 314 | + |
309 | 315 | namespace llvm {
|
310 | 316 | extern cl::opt<bool> EnableMemProfContextDisambiguation;
|
311 | 317 |
|
@@ -463,6 +469,9 @@ PassBuilder::buildO1FunctionSimplificationPipeline(OptimizationLevel Level,
|
463 | 469 | LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
|
464 | 470 | /*AllowSpeculation=*/false));
|
465 | 471 |
|
| 472 | + if (EnableLoopIterCountToAssumptions) |
| 473 | + LPM1.addPass(LoopIterCountAssumptions()); |
| 474 | + |
466 | 475 | LPM1.addPass(LoopRotatePass(/* Disable header duplication */ true,
|
467 | 476 | isLTOPreLink(Phase)));
|
468 | 477 | // TODO: Investigate promotion cap for O1.
|
@@ -644,6 +653,9 @@ PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
|
644 | 653 | LPM1.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
|
645 | 654 | /*AllowSpeculation=*/false));
|
646 | 655 |
|
| 656 | + if (EnableLoopIterCountToAssumptions) |
| 657 | + LPM1.addPass(LoopIterCountAssumptions()); |
| 658 | + |
647 | 659 | // Disable header duplication in loop rotation at -Oz.
|
648 | 660 | LPM1.addPass(LoopRotatePass(EnableLoopHeaderDuplication ||
|
649 | 661 | Level != OptimizationLevel::Oz,
|
|
0 commit comments