Skip to content

Commit

Permalink
[PassBuilder][PassManagerBuilder] Run LICM before loop spawning to en…
Browse files Browse the repository at this point in the history
…sure loop-invariant conditions appear outside of the loop. Addresses llvm#66.
  • Loading branch information
neboat committed Jul 1, 2023
1 parent 7f98738 commit 6d2ce44
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion llvm/lib/Passes/PassBuilderPipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1452,7 +1452,8 @@ PassBuilder::buildTapirLoweringPipeline(OptimizationLevel Level,
// Rotate Loop - disable header duplication at -Oz
LPM1.addPass(LoopRotatePass(Level != OptimizationLevel::Oz));
LPM2.addPass(IndVarSimplifyPass());
LPM2.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap));
LPM2.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
/*AllowSpeculation=*/true));

FunctionPassManager FPM;
FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM1),
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ void PassManagerBuilder::populateModulePassManager(
// rotated form due to GVN or other transformations, and loop spawning
// relies on the rotated form. Disable header duplication at -Oz.
MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
MPM.add(createLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap));
// Outline Tapir loops as needed.
MPM.add(createLoopSpawningTIPass());

Expand Down

0 comments on commit 6d2ce44

Please sign in to comment.