[flang-commits] [flang] [Flang][OpenMP] Skip unrelated passes in simd-only mode (PR #219193)
Kiran Chandramohan via flang-commits
flang-commits at lists.llvm.org
Thu Aug 27 06:52:28 PDT 2026
kiranchandramohan wrote:
> Tangentially to this patch: While looking at this, I was trying to figure out what the expected behavior was when `-fopenmp` and `-fopenmp-simd` are both present vs when only the latter is specified.
>
> At the moment, it looks like when both are present, then the resulting behavior is the same as if only `-fopenmp-simd` was specified. However, the description of the original patch (#150269) seems to state the opposite:
>
> > The flag is expected to have no effect if -fopenmp is passed explicitly [...]
>
> Is the current behavior what is expected or is what the original commit stated what we should be doing?
I agree with the behaviour described in the original commit, this seems to be the clang default as well. If that is not what is happening, then it could be due to last flag win defaults in the driver or an oversight. If your opinion is different we should check broadly.
But running a test locally, it looks to match what the commit says. My test is given below. Could you share your example and commandline?
```
subroutine test_openmp(a, b, n)
implicit none
integer, intent(in) :: n
real, intent(inout) :: a(n)
real, intent(in) :: b(n)
integer :: i
!$omp parallel
a(1) = a(1) + 1.0
!$omp end parallel
!$omp simd
do i = 1, n
a(i) = a(i) + b(i)
end do
!$omp end simd
end subroutine test_openmp
```
```
./bin/flang -S -emit-llvm simple.f90 -fopenmp -fopenmp-simd
```
```
...
call void (ptr, i32, ptr, ...) @__kmpc_fork_call(ptr @1, i32 1, ptr @test_openmp_..omp_par, ptr %structArg)
...
br label %omp_loop.header, !llvm.loop !6
...
!6 = distinct !{!6, !7, !8}
!7 = !{!"llvm.loop.parallel_accesses", !5}
!8 = !{!"llvm.loop.vectorize.enable"}
```
https://github.com/llvm/llvm-project/pull/219193
More information about the flang-commits
mailing list