[flang-commits] [flang] [flang] Added LoopInvariantCodeMotion pass for [HL]FIR. (PR #173438)

Tom Eccles via flang-commits flang-commits at lists.llvm.org
Mon Dec 29 03:22:52 PST 2025


================
@@ -206,6 +206,10 @@ void createDefaultFIROptimizerPassPipeline(mlir::PassManager &pm,
   pm.addPass(fir::createSimplifyRegionLite());
   pm.addPass(mlir::createCSEPass());
 
+  // Run LICM after CSE, which may reduce the number of operations to hoist.
+  if (pc.OptLevel.isOptimizingForSpeed())
+    pm.addPass(fir::createLoopInvariantCodeMotion());
----------------
tblah wrote:

If this doesn't currently lead to performance improvements, do we need to enable it by default? I'm worried this might be a relatively expensive pass.

I'm curious what the motivation is here more than anything. If there is a plan and you haven't observed serious compile time regressions then I am happy to see this on by default.

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


More information about the flang-commits mailing list