| 1 |
! { dg-additional-options "-fdump-tree-original" } |
| 2 |
! PR fortran/107424 |
| 3 |
|
| 4 |
module m |
| 5 |
contains |
| 6 |
subroutine foo (av, avo, a0, a0o, a1, a2, a3, a4) |
| 7 |
implicit none |
| 8 |
|
| 9 |
integer, value :: av |
| 10 |
integer, value, optional :: avo |
| 11 |
integer :: a0 |
| 12 |
integer, optional :: a0o |
| 13 |
integer, pointer :: a1 |
| 14 |
integer, pointer, optional :: a2 |
| 15 |
integer, allocatable :: a3 |
| 16 |
integer, allocatable, optional :: a4 |
| 17 |
integer :: a5 |
| 18 |
integer, pointer :: a6 |
| 19 |
integer, allocatable :: a7 |
| 20 |
integer :: arr(20,10), ref(20,10) |
| 21 |
|
| 22 |
integer :: j, i |
| 23 |
|
| 24 |
allocate(a6, a7) |
| 25 |
|
| 26 |
ref = 44 |
| 27 |
do i = 1, 10 |
| 28 |
do j = i, 20 |
| 29 |
ref(j, i) = j + 100 * i |
| 30 |
end do |
| 31 |
end do |
| 32 |
|
| 33 |
! { dg-final { scan-tree-dump-times "for \\(av = 1; av <= 10; av = av \\+ 1\\)" 1 "original" } } |
| 34 |
! { dg-final { scan-tree-dump-times "for \\(j = av \\* 1 \\+ 0; j <= 20; j = j \\+ 1\\)" 1 "original" } } |
| 35 |
! -> no temp var |
| 36 |
arr = 44 |
| 37 |
av = 99; j = 99 |
| 38 |
!$omp simd collapse(2) lastprivate(av,j) |
| 39 |
do av = 1, 10 |
| 40 |
do j = av, 20 |
| 41 |
arr(j, av) = j + 100 * av |
| 42 |
end do |
| 43 |
end do |
| 44 |
if (any (ref /= arr)) error stop |
| 45 |
if (av /= 11 .or. j /= 21) error stop |
| 46 |
|
| 47 |
! { dg-final { scan-tree-dump-times "for \\(avo = 1; avo <= 10; avo = avo \\+ 1\\)" 1 "original" } } |
| 48 |
! { dg-final { scan-tree-dump-times "for \\(j = avo \\* 1 \\+ 0; j <= 20; j = j \\+ 1\\)" 1 "original" } } |
| 49 |
! -> no temp var |
| 50 |
arr = 44 |
| 51 |
avo = 99; j = 99 |
| 52 |
!$omp simd collapse(2) lastprivate(avo, j) |
| 53 |
do avo = 1, 10 |
| 54 |
do j = avo, 20 |
| 55 |
arr(j, avo) = j + 100 * avo |
| 56 |
end do |
| 57 |
end do |
| 58 |
if (any (ref /= arr)) error stop |
| 59 |
if (avo /= 11 .or. j /= 21) error stop |
| 60 |
|
| 61 |
! { dg-final { scan-tree-dump-times "for \\(a0\\.\[0-9\]+ = 1; a0\\.\[0-9\]+ <= 10; a0\\.\[0-9\]+ = a0\\.\[0-9\]+ \\+ 1\\)" 1 "original" } } |
| 62 |
! { dg-final { scan-tree-dump-times "for \\(j = a0\\.\[0-9\]+ \\* 1 \\+ 0; j <= 20; j = j \\+ 1\\)" 1 "original" } } |
| 63 |
! { dg-final { scan-tree-dump-times "\\*a0 = a0\\.\[0-9\]+;" 1 "original" } } |
| 64 |
arr = 44 |
| 65 |
a0 = 99; j = 99 |
| 66 |
!$omp simd collapse(2) lastprivate(a0,j) |
| 67 |
do a0 = 1, 10 |
| 68 |
do j = a0, 20 |
| 69 |
arr(j, a0) = j + 100 * a0 |
| 70 |
end do |
| 71 |
end do |
| 72 |
if (any (ref /= arr)) error stop |
| 73 |
if (a0 /= 11 .or. j /= 21) error stop |
| 74 |
|
| 75 |
! { dg-final { scan-tree-dump-times "for \\(a0o\\.\[0-9\]+ = 1; a0o\\.\[0-9\]+ <= 10; a0o\\.\[0-9\]+ = a0o\\.\[0-9\]+ \\+ 1\\)" 1 "original" } } |
| 76 |
! { dg-final { scan-tree-dump-times "for \\(j = a0o\\.\[0-9\]+ \\* 1 \\+ 0; j <= 20; j = j \\+ 1\\)" 1 "original" } } |
| 77 |
! { dg-final { scan-tree-dump-times "\\*a0o = a0o\\.\[0-9\]+;" 1 "original" } } |
| 78 |
arr = 44 |
| 79 |
a0o = 99; j = 99 |
| 80 |
!$omp simd collapse(2) lastprivate(a0o,j) |
| 81 |
do a0o = 1, 10 |
| 82 |
do j = a0o, 20 |
| 83 |
arr(j, a0o) = j + 100 * a0o |
| 84 |
end do |
| 85 |
end do |
| 86 |
if (any (ref /= arr)) error stop |
| 87 |
if (a0o /= 11 .or. j /= 21) error stop |
| 88 |
|
| 89 |
! { dg-final { scan-tree-dump-times "for \\(a1\\.\[0-9\]+ = 1; a1\\.\[0-9\]+ <= 10; a1\\.\[0-9\]+ = a1\\.\[0-9\]+ \\+ 1\\)" 1 "original" } } |
| 90 |
! { dg-final { scan-tree-dump-times "for \\(j = a1\\.\[0-9\]+ \\* 1 \\+ 0; j <= 20; j = j \\+ 1\\)" 1 "original" } } |
| 91 |
! { dg-final { scan-tree-dump-times "\\*\\*a1 = a1\\.\[0-9\]+;" 1 "original" } } |
| 92 |
arr = 44 |
| 93 |
a1 = 99; j = 99 |
| 94 |
! no last private for 'a1' as "The initial status of a private pointer is undefined." |
| 95 |
!$omp simd collapse(2) lastprivate(j) |
| 96 |
do a1 = 1, 10 |
| 97 |
do j = a1, 20 |
| 98 |
arr(j, a1) = j + 100 * a1 |
| 99 |
end do |
| 100 |
end do |
| 101 |
if (any (ref /= arr)) error stop |
| 102 |
if (j /= 21) error stop |
| 103 |
|
| 104 |
! { dg-final { scan-tree-dump-times "for \\(a2\\.\[0-9\]+ = 1; a2\\.\[0-9\]+ <= 10; a2\\.\[0-9\]+ = a2\\.\[0-9\]+ \\+ 1\\)" 1 "original" } } |
| 105 |
! { dg-final { scan-tree-dump-times "for \\(j = a2\\.\[0-9\]+ \\* 1 \\+ 0; j <= 20; j = j \\+ 1\\)" 1 "original" } } |
| 106 |
! { dg-final { scan-tree-dump-times "\\*\\*a2 = a2\\.\[0-9\]+;" 1 "original" } } |
| 107 |
arr = 44 |
| 108 |
a2 = 99; j = 99 |
| 109 |
! no last private for 'a2' as "The initial status of a private pointer is undefined." |
| 110 |
!$omp simd collapse(2) lastprivate(j) |
| 111 |
do a2 = 1, 10 |
| 112 |
do j = a2, 20 |
| 113 |
arr(j, a2) = j + 100 * a2 |
| 114 |
end do |
| 115 |
end do |
| 116 |
if (any (ref /= arr)) error stop |
| 117 |
if (j /= 21) error stop |
| 118 |
|
| 119 |
! { dg-final { scan-tree-dump-times "for \\(a3\\.\[0-9\]+ = 1; a3\\.\[0-9\]+ <= 10; a3\\.\[0-9\]+ = a3\\.\[0-9\]+ \\+ 1\\)" 1 "original" } } |
| 120 |
! { dg-final { scan-tree-dump-times "for \\(j = a3\\.\[0-9\]+ \\* 1 \\+ 0; j <= 20; j = j \\+ 1\\)" 1 "original" } } |
| 121 |
! { dg-final { scan-tree-dump-times "\\*\\*a3 = a3\\.\[0-9\]+;" 1 "original" } } |
| 122 |
arr = 44 |
| 123 |
a3 = 99; j = 99 |
| 124 |
!$omp simd collapse(2) lastprivate(a3,j) |
| 125 |
do a3 = 1, 10 |
| 126 |
do j = a3, 20 |
| 127 |
arr(j, a3) = j + 100 * a3 |
| 128 |
end do |
| 129 |
end do |
| 130 |
if (any (ref /= arr)) error stop |
| 131 |
if (a3 /= 11 .or. j /= 21) error stop |
| 132 |
|
| 133 |
! { dg-final { scan-tree-dump-times "for \\(a4\\.\[0-9\]+ = 1; a4\\.\[0-9\]+ <= 10; a4\\.\[0-9\]+ = a4\\.\[0-9\]+ \\+ 1\\)" 1 "original" } } |
| 134 |
! { dg-final { scan-tree-dump-times "for \\(j = a4\\.\[0-9\]+ \\* 1 \\+ 0; j <= 20; j = j \\+ 1\\)" 1 "original" } } |
| 135 |
! { dg-final { scan-tree-dump-times "\\*\\*a4 = a4\\.\[0-9\]+;" 1 "original" } } |
| 136 |
arr = 44 |
| 137 |
a4 = 99; j = 99 |
| 138 |
!$omp simd collapse(2) lastprivate(a4,j) |
| 139 |
do a4 = 1, 10 |
| 140 |
do j = a4, 20 |
| 141 |
arr(j, a4) = j + 100 * a4 |
| 142 |
end do |
| 143 |
end do |
| 144 |
if (any (ref /= arr)) error stop |
| 145 |
if (a4 /= 11 .or. j /= 21) error stop |
| 146 |
|
| 147 |
! { dg-final { scan-tree-dump-times "for \\(a5 = 1; a5 <= 10; a5 = a5 \\+ 1\\)" 1 "original" } } |
| 148 |
! { dg-final { scan-tree-dump-times "for \\(j = a5 \\* 1 \\+ 0; j <= 20; j = j \\+ 1\\)" 1 "original" } } |
| 149 |
! -> no temp var |
| 150 |
arr = 44 |
| 151 |
a5 = 99; j = 99 |
| 152 |
!$omp simd collapse(2) lastprivate(a5,j) |
| 153 |
do a5 = 1, 10 |
| 154 |
do j = a5, 20 |
| 155 |
arr(j, a5) = j + 100 * a5 |
| 156 |
end do |
| 157 |
end do |
| 158 |
if (any (ref /= arr)) error stop |
| 159 |
if (a5 /= 11 .or. j /= 21) error stop |
| 160 |
|
| 161 |
! { dg-final { scan-tree-dump-times "for \\(a6\\.\[0-9\]+ = 1; a6\\.\[0-9\]+ <= 10; a6\\.\[0-9\]+ = a6\\.\[0-9\]+ \\+ 1\\)" 1 "original" } } |
| 162 |
! { dg-final { scan-tree-dump-times "for \\(j = a6\\.\[0-9\]+ \\* 1 \\+ 0; j <= 20; j = j \\+ 1\\)" 1 "original" } } |
| 163 |
! { dg-final { scan-tree-dump-times "\\*a6 = a6\\.\[0-9\]+;" 1 "original" } } |
| 164 |
arr = 44 |
| 165 |
a6 = 99; j = 99 |
| 166 |
! no last private for 'a6' as "The initial status of a private pointer is undefined." |
| 167 |
!$omp simd collapse(2) lastprivate(j) |
| 168 |
do a6 = 1, 10 |
| 169 |
do j = a6, 20 |
| 170 |
arr(j, a6) = j + 100 * a6 |
| 171 |
end do |
| 172 |
end do |
| 173 |
if (any (ref /= arr)) error stop |
| 174 |
if (j /= 21) error stop |
| 175 |
|
| 176 |
! { dg-final { scan-tree-dump-times "for \\(a7\\.\[0-9\]+ = 1; a7\\.\[0-9\]+ <= 10; a7\\.\[0-9\]+ = a7\\.\[0-9\]+ \\+ 1\\)" 1 "original" } } |
| 177 |
! { dg-final { scan-tree-dump-times "for \\(j = a7\\.\[0-9\]+ \\* 1 \\+ 0; j <= 20; j = j \\+ 1\\)" 1 "original" } } |
| 178 |
! { dg-final { scan-tree-dump-times "\\*a7 = a7\\.\[0-9\]+;" 1 "original" } } |
| 179 |
arr = 44 |
| 180 |
a7 = 99; j = 99 |
| 181 |
!$omp simd collapse(2) lastprivate(a7,j) |
| 182 |
do a7 = 1, 10 |
| 183 |
do j = a7, 20 |
| 184 |
arr(j, a7) = j + 100 * a7 |
| 185 |
end do |
| 186 |
end do |
| 187 |
if (any (ref /= arr)) error stop |
| 188 |
if (a7 /= 11 .or. j /= 21) error stop |
| 189 |
|
| 190 |
deallocate(a6, a7) |
| 191 |
end |
| 192 |
|
| 193 |
end module m |
| 194 |
|
| 195 |
|
| 196 |
use m |
| 197 |
implicit none |
| 198 |
|
| 199 |
integer :: av |
| 200 |
integer :: avo |
| 201 |
integer :: a0 |
| 202 |
integer :: a0o |
| 203 |
integer, pointer :: a1 |
| 204 |
integer, pointer :: a2 |
| 205 |
integer, allocatable :: a3 |
| 206 |
integer, allocatable :: a4 |
| 207 |
|
| 208 |
av = -99; avo = -99 |
| 209 |
allocate(a1,a2,a3,a4) |
| 210 |
call foo (av, avo, a0, a0o, a1, a2, a3, a4) |
| 211 |
deallocate(a1,a2,a3,a4) |
| 212 |
end |