1! PR middle-end/66199
2! { dg-options "-O2" }
3
4  integer :: u(1024), v(1024), w(1024), a, b, c, d, e, a1, b1, a2, b2, d1, d2
5  a = 1
6  b = 1024
7  d = 75
8  !$omp target teams distribute parallel do simd default(none) &
9  !$omp& firstprivate (a, b) shared(u, v, w)
10  do d = a, b
11    u(d) = v(d) + w(d)
12  end do
13  c = 17
14  d = 75
15  !$omp target teams distribute parallel do simd default(none) &
16  !$omp& firstprivate (a, b, c) shared(u, v, w) &
17  !$omp& linear(d) lastprivate(e)
18  do d = a, b
19    u(d) = v(d) + w(d)
20    e = c + d * 5
21  end do
22  a1 = 0
23  a2 = 0
24  b1 = 31
25  b2 = 31
26  d1 = 7
27  d2 = 9
28  !$omp target teams distribute parallel do simd default(none) &
29  !$omp& firstprivate (a1, b1, a2, b2) &
30  !$omp& shared(u, v, w) lastprivate(d1, d2) collapse(2)
31  do d1 = a1, b1
32    do d2 = a2, b2
33      u(d1 * 32 + d2 + 1) = v(d1 * 32 + d2 + 1) + w(d1 * 32 + d2 + 1)
34    end do
35  end do
36  d1 = 7
37  d2 = 9
38  !$omp target teams distribute parallel do simd default(none) &
39  !$omp& firstprivate (a1, b1, a2, b2) shared(u, v, w) collapse(2)
40  do d1 = a1, b1
41    do d2 = a2, b2
42      u(d1 * 32 + d2 + 1) = v(d1 * 32 + d2 + 1) + w(d1 * 32 + d2 + 1)
43    end do
44  end do
45end
46