[LoopReroll] Add an extra defensive check to avoid SCEV assertion.
[llvm-project.git] / flang / test / Semantics / OpenACC / acc-serial-loop.f90
blobc088bf892e78a4a4dd7d8743eaba2c6e50fed87a
1 ! RUN: %S/../test_errors.sh %s %t %flang -fopenacc
2 ! REQUIRES: shell
4 ! Check OpenACC clause validity for the following construct and directive:
5 ! 2.11 Serial Loop
7 program openacc_serial_loop_validity
9 implicit none
11 integer :: i, b
12 integer, parameter :: N = 256
13 integer, dimension(N) :: c
14 logical, dimension(N) :: d, e
15 integer :: async1
16 integer :: wait1, wait2
17 real :: reduction_r
18 logical :: reduction_l
19 logical :: ifCondition = .TRUE.
20 real(8), dimension(N) :: a
23 !$acc serial loop reduction(+: reduction_r)
24 do i = 1, N
25 reduction_r = a(i) + i
26 end do
28 !$acc serial loop reduction(*: reduction_r)
29 do i = 1, N
30 reduction_r = reduction_r * (a(i) + i)
31 end do
33 !$acc serial loop reduction(min: reduction_r)
34 do i = 1, N
35 reduction_r = min(reduction_r, a(i) * i)
36 end do
38 !$acc serial loop reduction(max: reduction_r)
39 do i = 1, N
40 reduction_r = max(reduction_r, a(i) * i)
41 end do
43 !$acc serial loop reduction(iand: b)
44 do i = 1, N
45 b = iand(b, c(i))
46 end do
48 !$acc serial loop reduction(ior: b)
49 do i = 1, N
50 b = ior(b, c(i))
51 end do
53 !$acc serial loop reduction(ieor: b)
54 do i = 1, N
55 b = ieor(b, c(i))
56 end do
58 !$acc serial loop reduction(.and.: reduction_l)
59 do i = 1, N
60 reduction_l = d(i) .and. e(i)
61 end do
63 !$acc serial loop reduction(.or.: reduction_l)
64 do i = 1, N
65 reduction_l = d(i) .or. e(i)
66 end do
68 !$acc serial loop reduction(.eqv.: reduction_l)
69 do i = 1, N
70 reduction_l = d(i) .eqv. e(i)
71 end do
73 !$acc serial loop reduction(.neqv.: reduction_l)
74 do i = 1, N
75 reduction_l = d(i) .neqv. e(i)
76 end do
78 !ERROR: Clause IF is not allowed after clause DEVICE_TYPE on the SERIAL LOOP directive
79 !$acc serial loop device_type(*) if(.TRUE.)
80 do i = 1, N
81 a(i) = 3.14
82 end do
83 !$acc end serial loop
85 !$acc serial loop if(ifCondition)
86 do i = 1, N
87 a(i) = 3.14
88 end do
89 !$acc end serial loop
91 !$acc serial loop
92 do i = 1, N
93 a(i) = 3.14
94 end do
95 !ERROR: Unmatched END PARALLEL LOOP directive
96 !$acc end parallel loop
98 end program openacc_serial_loop_validity