Debian Codegraph @

libgomp/testsuite/libgomp.fortran/unroll-2.f90

raw
1 ! { dg-do run }
2 ! { dg-additional-options "-g" }
3
4 module test_functions
5 contains
6 integer function compute_sum1 () result(sum)
7 implicit none
8 integer :: i
9
10 sum = 0
11 !$omp unroll full
12 do i = 1,10,3
13 sum = sum + 1
14 end do
15 end function compute_sum1
16
17 integer function compute_sum2() result(sum)
18 implicit none
19 integer :: i
20
21 sum = 0
22 !$omp unroll full
23 do i = -20,1,3
24 sum = sum + 1
25 end do
26 end function compute_sum2
27
28 integer function compute_sum3() result(sum)
29 implicit none
30 integer :: i
31
32 sum = 0
33 !$omp unroll full
34 do i = 30,1,-3
35 sum = sum + 1
36 end do
37 end function compute_sum3
38
39 integer function compute_sum4() result(sum)
40 implicit none
41 integer :: i
42
43 sum = 0
44 !$omp unroll full
45 do i = 50,-60,-10
46 sum = sum + 1
47 end do
48 end function compute_sum4
49
50 end module test_functions
51
52 program test
53 use test_functions
54 implicit none
55 integer :: result
56
57 result = compute_sum1 ()
58 if (result .ne. 4) then
59 stop 1
60 end if
61
62 result = compute_sum2 ()
63 if (result .ne. 8) then
64 stop 2
65 end if
66
67 result = compute_sum3 ()
68 if (result .ne. 10) then
69 stop 3
70 end if
71
72 result = compute_sum4 ()
73 if (result .ne. 12) then
74 stop 4
75 end if
76 end program