[flang-commits] [flang] [flang][OpenMP] Fix standalone SIMD directive post-loop variable value (PR #196731)
Leandro Lupori via flang-commits
flang-commits at lists.llvm.org
Fri Aug 14 10:49:30 PDT 2026
https://github.com/luporl commented:
This looks similar to #213947, although it handles other worksharing/loop constructs. It should work for variables with implicit DSA, but not for explicit ones. Example:
```f90
i = 100
!$omp do simd linear(i)
do i = 1, 10
end do
print *, i
```
This prints 11. Should the linear clause be applied only to `simd` here?
Currently, linear is applied to both `do` and `simd`:
```
omp.wsloop linear(%2#0 : !fir.ref<i32> = %c1_i32 : i32) {
omp.simd linear(%2#0 : !fir.ref<i32> = %c1_i32_1 : i32) {
```
#213947 also overrides explicit DSAs in semantics, but somewhere in lowering (probably the part that handles composite/combined constructs) linear is applied to `omp.wsloop`, which results in:
```
omp.wsloop linear(%2#0 : !fir.ref<i32> = %c1_i32_1 : i32) {
omp.simd private(@_QFEi_private_i32 %2#0 -> %arg0 : !fir.ref<i32>) {
```
So handling the case above would require a change in lowering, ideally to produce this MLIR output:
```
omp.wsloop private(@_QFEi_private_i32 %2#0 -> %arg0 : !fir.ref<i32>) {
omp.simd linear(%2#0 : !fir.ref<i32> = %c1_i32_1 : i32) {
```
https://github.com/llvm/llvm-project/pull/196731
More information about the flang-commits
mailing list