[all-commits] [llvm/llvm-project] 304c66: [flang][OpenMP] Support lowering of metadirective ...
Chi-Chun, Chen via All-commits
all-commits at lists.llvm.org
Fri Jul 10 12:41:42 PDT 2026
Branch: refs/heads/users/cchen/flang-metadirective-loop-lowering
Home: https://github.com/llvm/llvm-project
Commit: 304c66040a4b09f4cb44c1bea96354bb1593e35f
https://github.com/llvm/llvm-project/commit/304c66040a4b09f4cb44c1bea96354bb1593e35f
Author: Chi Chun, Chen <chichun.chen at hpe.com>
Date: 2026-07-10 (Fri, 10 Jul 2026)
Changed paths:
M flang/lib/Lower/OpenMP/DataSharingProcessor.cpp
M flang/lib/Lower/OpenMP/OpenMP.cpp
M flang/lib/Lower/OpenMP/Utils.cpp
M flang/lib/Lower/OpenMP/Utils.h
R flang/test/Lower/OpenMP/Todo/metadirective-loop.f90
A flang/test/Lower/OpenMP/Todo/metadirective-module-loop.f90
A flang/test/Lower/OpenMP/Todo/metadirective-target-loop.f90
A flang/test/Lower/OpenMP/metadirective-loop.f90
Log Message:
-----------
[flang][OpenMP] Support lowering of metadirective (part 3)
Enable lowering of metadirectives that resolve to a loop-associated
variant such as `do`, `simd`, `parallel do`, and `do simd`. The
associated DO construct is made available to the selected variant so the
existing OpenMP loop lowering can process it. A standalone metadirective
uses the following sibling DO, and a begin/end metadirective uses the
first substantive evaluation nested in its block.
For example, when the `vendor(llvm)` selector matches, the `parallel do`
variant is lowered together with the DO loop that follows it:
```fortran
!$omp metadirective when(implementation={vendor(llvm)}: parallel do)
do i = 1, n
y(i) = a*x(i) + y(i)
end do
```
```mlir
omp.parallel {
omp.wsloop {
omp.loop_nest (%iv) = (%lb) to (%ub) ... { ... }
}
}
```
Because semantic analysis cannot know which variant is selected,
induction-variable data-sharing attributes are marked during lowering and
scoped to the selected variant, so DSA state does not leak between
alternatives. A variant that opens a parallel, task, or teams region also
privatizes the indices of its nested sequential loops. `collapse(n)` and
`ordered(n)` use the normal affected-loop-depth calculation, and SIMD
variants are recognized from their leaf constructs.
Dynamic selection preserves the associated DO evaluation in every arm, so
a runtime `condition(flag)` that may pick a loop-associated variant or a
standalone fallback does not drop the loop body from the fallback arm.
Lowering assumes the associated loop nest is a canonical DO nest that is
deep enough for any `collapse(n)` or `ordered(n)`. The merged metadirective
loop-nest semantic checks
([#207088](https://github.com/llvm/llvm-project/pull/207088)) reject a DO
WHILE, a missing or non-canonical loop, and an oversized `collapse`/`ordered`,
so a malformed nest does not reach lowering in a valid test.
Part of the feature work for #188820.
Assisted with Copilot.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list