[llvm] [Passes] Add option for LoopVersioningLICM pass. (PR #67107)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 25 23:53:49 PDT 2023


================
@@ -1293,6 +1298,21 @@ PassBuilder::buildModuleOptimizationPipeline(OptimizationLevel Level,
   if (RunPartialInlining)
     MPM.addPass(PartialInlinerPass());
 
+  // Scheduling LoopVersioningLICM when inlining is over, because after that
+  // we may see more accurate aliasing. Reason to run this late is that too
+  // early versioning may prevent further inlining due to increase of code
+  // size. By placing it just after inlining other optimizations which runs
+  // later might get benefit of no-alias assumption in clone loop.
+  if (UseLoopVersioningLICM) {
+    MPM.addPass(createModuleToFunctionPassAdaptor(
+        createFunctionToLoopPassAdaptor(LoopVersioningLICMPass())));
+    MPM.addPass(
+        createModuleToFunctionPassAdaptor(createFunctionToLoopPassAdaptor(
+            LICMPass(PTO.LicmMssaOptCap, PTO.LicmMssaNoAccForPromotionCap,
+                     /*AllowSpeculation=*/true),
+            /*USeMemorySSA=*/true, /*UseBlockFrequencyInfo=*/false)));
+  }
----------------
nikic wrote:

I think this should be moved into the OptimizePM below. There doesn't seems to be a good reason to run this earlier with a separate FPM.

https://github.com/llvm/llvm-project/pull/67107


More information about the llvm-commits mailing list