[flang-commits] [flang] [mlir] [Flang][OpenMP] Support iterator modifier in map and motion clauses (PR #197757)

via flang-commits flang-commits at lists.llvm.org
Wed Sep 16 21:24:07 PDT 2026


================
@@ -1514,7 +1559,7 @@ bool ClauseProcessor::processDepend(lower::SymMap &symMap,
 
     llvm::SmallVector<IteratorRange> iteratorRanges;
     llvm::SmallPtrSet<const Fortran::semantics::Symbol *, 4> ivSyms;
-    collectIteratorIVs(clause, converter, stmtCtx, iteratorRanges, ivSyms);
+    collectIteratorIVs(clause, converter, stmtCtx, iteratorRanges, &ivSyms);
----------------
MattPD wrote:

The description states that each locator is expanded only over the iterators that appear in it. The map and motion path follows that per-locator rule. `depend` and `affinity` still build one `omp.iterator` over every range for every object. For this program:

```fortran
subroutine s(a)
  integer :: a(2)
  !$omp task depend(iterator(i=1:2, j=2:1), in: a(i))
  !$omp end task
end subroutine
```

At dcc6653, `flang -fc1 -emit-llvm -fopenmp -fopenmp-version=52` passes 0 dependences to `__kmpc_omp_task_with_deps`. Dropping `j` gives 2 dependences. The same iterator modifier on a `target update` motion clause yields a one-dimensional iterator over `i`.

OpenMP 5.2 section 3.2.6 applies the substitution per iterator identifier that appears in the list item, so the map path matches the standard. At 82004b0 the `omp.iterator` verifier rejected this constant form. A dynamic `j=2:m` with `m=1` already lowered to zero dependences before this PR. Only the constant form is new here.

Is aligning `depend` and `affinity` with the per-locator rule in scope for this PR, or should it be tracked separately?

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


More information about the flang-commits mailing list