1! { dg-additional-options "-O2" }
2! { dg-additional-options "-fdump-tree-parloops1-all" }
3! { dg-additional-options "-fdump-tree-optimized" }
4
5module test
6contains
7  subroutine foo(n)
8    implicit none
9    integer :: n
10    integer, dimension (0:n-1) :: a, b, c
11    integer                    :: i, ii
12    do i = 0, n - 1
13       a(i) = i * 2
14    end do
15
16    do i = 0, n -1
17       b(i) = i * 4
18    end do
19
20    !$acc kernels copyin (a(0:n-1), b(0:n-1)) copyout (c(0:n-1))
21    do ii = 0, n - 1
22       c(ii) = a(ii) + b(ii)
23    end do
24    !$acc end kernels
25
26    do i = 0, n - 1
27       if (c(i) .ne. a(i) + b(i)) STOP 1
28    end do
29
30  end subroutine foo
31end module test
32
33! Check that only one loop is analyzed, and that it can be parallelized.
34! { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } }
35! TODO, PR70545.
36! { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels parallelized, oacc function \\(, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" { xfail *-*-* } } }
37! { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } }
38
39! Check that the loop has been split off into a function.
40! { dg-final { scan-tree-dump-times "(?n);; Function __test_MOD_foo._omp_fn.0 " 1 "optimized" } }
41