[flang-commits] [flang] [flang] Decouple HLFIR array expansion from optimization level (PR #233478)

via flang-commits flang-commits at lists.llvm.org
Mon Oct 19 13:47:54 PDT 2026


================
@@ -151,6 +153,9 @@ struct MLIRToLLVMPassPipelineConfig : public FlangEPCallBacks {
   }
 
   llvm::OptimizationLevel OptLevel; ///< optimisation level
+  /// Prefer runtime calls over inline expansion of HLFIR array operations.
+  /// Scalar-to-array assignments are still inlined when possible.
+  bool useArrayRuntime = true;
----------------
jeanPerier wrote:

Renamed the setting to optimizeArrayExpression. It intentionally enables HLFIR
optimizations, with expensive ones still gated at O3, so I kept a short comment
describing that policy rather than listing individual passes. I prefer comment describing the general intent rather than duplicating the details of the code. Also delegated
the constructor and removed the redundant initializer.

HLFIR main purpose is array optimizations (avoiding array temporaries/runtime calls). CSE/Canonicalizer are already run at O0 in the FIR pipeline, so there is not much new here, this is needed for array optimization pattern matching to remain simple.

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


More information about the flang-commits mailing list