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