[flang-commits] [clang] [flang] [llvm] [Flang][LoopUnroll][Transforms] Add LoopUnrollForVectorization pass (PR #202444)
Nikita Popov via flang-commits
flang-commits at lists.llvm.org
Tue Jun 16 03:49:03 PDT 2026
================
@@ -1344,6 +1346,24 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
void PassBuilder::addVectorPasses(OptimizationLevel Level,
FunctionPassManager &FPM,
ThinOrFullLTOPhase LTOPhase) {
+ const bool IsFullLTO = LTOPhase == ThinOrFullLTOPhase::FullLTOPostLink;
+
+ if (!IsFullLTO && Level == OptimizationLevel::O3 && PTO.LoopUnrolling &&
+ EnableOuterLoopVecPrep) {
+ FPM.addPass(LoopUnrollForVectorizationPass());
+ FPM.addPass(ReassociatePass());
+ FPM.addPass(createFunctionToLoopPassAdaptor(
+ LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
+ /*AllowSpeculation=*/true),
+ /*UseMemorySSA=*/true));
+ FPM.addPass(GVNPass());
+ FPM.addPass(createFunctionToLoopPassAdaptor(
+ LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
+ /*AllowSpeculation=*/true),
+ /*UseMemorySSA=*/true));
+ FPM.addPass(InstCombinePass());
----------------
nikic wrote:
This is running lots of additional passes even if no unrolling happened. If you want to run extra passes you need to make them conditional on successful unrolling.
But imho this is indication that the unroll happens too late.
https://github.com/llvm/llvm-project/pull/202444
More information about the flang-commits
mailing list