[llvm-branch-commits] [flang] [mlir] [Flang][MLIR] Add `!$omp unroll` and `omp.unroll_heuristic` (PR #144785)

Michael Kruse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Jul 9 14:53:41 PDT 2025


================
@@ -2154,6 +2176,163 @@ genLoopOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
   return loopOp;
 }
 
+static mlir::omp::CanonicalLoopOp
+genCanonicalLoopOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
+                   semantics::SemanticsContext &semaCtx,
+                   lower::pft::Evaluation &eval, mlir::Location loc,
+                   const ConstructQueue &queue,
+                   ConstructQueue::const_iterator item,
+                   llvm::ArrayRef<const semantics::Symbol *> ivs,
+                   llvm::omp::Directive directive, DataSharingProcessor &dsp) {
+  fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
+
+  assert(ivs.size() == 1 && "Nested loops not yet implemented");
----------------
Meinersbur wrote:

It is currently only called by genUnrollOp which only supports a single loop, and can only call `genCanonicalLoopOp` with a single loop. Anything that would use genCanonicalLoopOp for nests with multiple loops with need to update the implementation: Probably a `genCanonicalLoopNest` that calls `genCanonicalLoopOp` multiple times, once for each loop. That is, calling `genCanonicalLoopOp` with more than one iv would be a API usage error[^1], not a "not yet implemented".

[^1]: Probably `genCanonicalLoopNest` gets the `ArrayRef` and passes each matching `semantics::Symbol *` to a call of `genCanonicalLoopOp`, we will see.

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


More information about the llvm-branch-commits mailing list