1! { dg-do compile }
2! { dg-options "-O -fdump-tree-cunroll-details -fdump-rtl-loop2_unroll-details" }
3! Test that
4! #pragma GCC unroll n
5! works
6
7subroutine test1(a)
8  implicit NONE
9  integer :: a(8)
10  integer (kind=4) :: i
11!GCC$ unroll 8
12  DO i=1, 8, 1
13    call dummy(a(i))
14  ENDDO
15! { dg-final { scan-tree-dump "12:.*: loop with 7 iterations completely unrolled" "cunroll" } } */
16end subroutine test1
17
18subroutine test2(a, n)
19  implicit NONE
20  integer :: a(n)
21  integer (kind=1), intent(in) :: n
22  integer (kind=4) :: i
23!GCC$ unroll 8
24  DO i=1, n, 1
25    call dummy(a(i))
26  ENDDO
27! { dg-final { scan-rtl-dump "24:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
28end subroutine test2
29
30subroutine test3(a, n)
31  implicit NONE
32  integer (kind=1), intent(in) :: n
33  integer :: a(n)
34  integer (kind=4) :: i
35!GCC$ unroll 8
36  DO i=n, 1, -1
37    call dummy(a(i))
38  ENDDO
39! { dg-final { scan-rtl-dump "36:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
40end subroutine test3
41
42subroutine test4(a, n)
43  implicit NONE
44  integer (kind=1), intent(in) :: n
45  integer :: a(n)
46  integer (kind=4) :: i
47!GCC$ unroll 8
48  DO i=1, n, 2
49    call dummy(a(i))
50  ENDDO
51! { dg-final { scan-rtl-dump "48:.: optimized: loop unrolled 7 times" "loop2_unroll" } }
52end subroutine test4
53