[flang-commits] [flang] [flang][OpenMP] Implement collapse for imperfectly nested loops (PR #202435)

Sergio Afonso via flang-commits flang-commits at lists.llvm.org
Thu Jul 9 05:58:59 PDT 2026


skatrak wrote:

@cenewcombe this commit seems to have caused a regression on labeled DO loops in cases where loop bounds are host evaluated. I have confirmed reverting this commit fixes it back. Here's a reproducer:
```f90
! repro.f90
! flang -c -fopenmp --offload-arch=gfx90a repro.f90

SUBROUTINE INITAL(N, M)
  IMPLICIT NONE

  INTEGER, INTENT(IN) :: N,M
  INTEGER :: I,J

  !$omp target parallel do collapse(2)
  DO 10 J=1,N
  DO 11 I=1,M
  11 END DO
  10 END DO

  !$omp target teams distribute parallel do collapse(2)
  DO 20 J=1,N
  DO 21 I=1,M
  21 END DO
  20 END DO

  !$omp target teams distribute collapse(2)
  DO 30 J=1,N
  DO 31 I=1,M
  31 END DO
  30 END DO
END SUBROUTINE
```
It now produces the MLIR verifier error "'omp.target' op host_eval argument illegal use in 'arith.addi' operation" on all three target regions. Without looking at it in depth, it looks like what may be happening is that an `omp.target host_eval`-related entry block argument is being used instead of the mapped version of that same value.

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


More information about the flang-commits mailing list