Skip to content

Commit 7422bec

Browse files
committed
[PassBuilder][PassManagerBuilder] Run LICM before loop spawning to ensure loop-invariant conditions appear outside of the loop. Addresses llvm#66.
1 parent 0a706be commit 7422bec

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,7 +1336,8 @@ PassBuilder::buildTapirLoweringPipeline(OptimizationLevel Level,
13361336
// Rotate Loop - disable header duplication at -Oz
13371337
LPM1.addPass(LoopRotatePass(Level != OptimizationLevel::Oz));
13381338
LPM2.addPass(IndVarSimplifyPass());
1339-
LPM2.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap));
1339+
LPM2.addPass(LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
1340+
/*AllowSpeculation=*/true));
13401341

13411342
FunctionPassManager FPM;
13421343
FPM.addPass(createFunctionToLoopPassAdaptor(std::move(LPM1),

llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,6 +1087,7 @@ void PassManagerBuilder::populateModulePassManager(
10871087
// rotated form due to GVN or other transformations, and loop spawning
10881088
// relies on the rotated form. Disable header duplication at -Oz.
10891089
MPM.add(createLoopRotatePass(SizeLevel == 2 ? 0 : -1));
1090+
MPM.add(createLICMPass(LicmMssaOptCap, LicmMssaNoAccForPromotionCap));
10901091
// Outline Tapir loops as needed.
10911092
MPM.add(createLoopSpawningTIPass());
10921093
if (VerifyTapir)

0 commit comments

Comments
 (0)