[flang-commits] [flang] [flang][fir] Add affine optimization pass pipeline. (PR #138627)

via flang-commits flang-commits at lists.llvm.org
Fri May 9 00:21:27 PDT 2025


================
@@ -209,8 +209,25 @@ void createDefaultFIROptimizerPassPipeline(mlir::PassManager &pm,
   if (pc.AliasAnalysis && !disableFirAliasTags && !useOldAliasTags)
     pm.addPass(fir::createAddAliasTags());
 
+  if (enableAffineOpt && pc.OptLevel.isOptimizingForSpeed()) {
----------------
jeanPerier wrote:

Can you add a comment that this is experimental?

The PromoteToAffinePass was an internship prototype created 4-5 years ago, and it has not been actively tested on a big Fortran code base (unless you have).

I also share the opinion that automatic promotion of array expressions to OpenMP parallel region is tricky without some very good heuristic that guess if it is worth it (e.g., big enough to justify launching threads/kernel).

Also, while Affine has very nice features when you can map to it, my experience from this early experiment is that the loops we can map to affine starting from Fortran loops are limited. Therefore, I am not convinced affine should be a required step/the solution towards automatic parallelization of Fortran code.
Going towards SCF and core dialects would be more promising in my opinion.

Getting more experience/metric is still interesting though, thank you for the patch!

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


More information about the flang-commits mailing list