| 1 |
! { dg-options "-O3 -fdump-tree-lversion-details -fno-frontend-loop-interchange" } |
| 2 |
|
| 3 |
! Test cases in which versioning is useful for a two-dimensional array. |
| 4 |
|
| 5 |
subroutine f1(x) |
| 6 |
real :: x(:, :) |
| 7 |
x(:, :) = 100 |
| 8 |
end subroutine f1 |
| 9 |
|
| 10 |
subroutine f2(x) |
| 11 |
real :: x(:, :) |
| 12 |
do i = lbound(x, 1), ubound(x, 1) |
| 13 |
do j = lbound(x, 2), ubound(x, 2) |
| 14 |
x(j, i) = 100 |
| 15 |
end do |
| 16 |
end do |
| 17 |
end subroutine f2 |
| 18 |
|
| 19 |
subroutine f3(x, n, step) |
| 20 |
integer :: n, step |
| 21 |
real :: x(100, 100) |
| 22 |
do i = 1, n |
| 23 |
do j = 1, n |
| 24 |
x(j * step, i) = 100 |
| 25 |
end do |
| 26 |
end do |
| 27 |
end subroutine f3 |
| 28 |
|
| 29 |
subroutine f4(x, n, step) |
| 30 |
integer :: n, step |
| 31 |
real :: x(n * step, n) |
| 32 |
do i = 1, n |
| 33 |
do j = 1, n |
| 34 |
x(j * step, i) = 100 |
| 35 |
end do |
| 36 |
end do |
| 37 |
end subroutine f4 |
| 38 |
|
| 39 |
subroutine f5(x, n, limit, step) |
| 40 |
integer :: n, limit, step |
| 41 |
real :: x(limit, n) |
| 42 |
do i = 1, n |
| 43 |
do j = 1, limit, step |
| 44 |
x(j, i) = 100 |
| 45 |
end do |
| 46 |
end do |
| 47 |
end subroutine f5 |
| 48 |
|
| 49 |
subroutine f6(x, y) |
| 50 |
real :: x(:, :), y(:) |
| 51 |
do i = lbound(x, 1), ubound(x, 1) |
| 52 |
do j = lbound(x, 2), ubound(x, 2) |
| 53 |
x(j, i) = 100 |
| 54 |
end do |
| 55 |
y(i) = 200 |
| 56 |
end do |
| 57 |
end subroutine f6 |
| 58 |
|
| 59 |
subroutine f7(x, y, n, step) |
| 60 |
integer :: n, step |
| 61 |
real :: x(100, 100), y(100) |
| 62 |
do i = 1, n |
| 63 |
do j = 1, n |
| 64 |
x(j * step, i) = 100 |
| 65 |
end do |
| 66 |
y(i * step) = 200 |
| 67 |
end do |
| 68 |
end subroutine f7 |
| 69 |
|
| 70 |
subroutine f8(x, y, n, step) |
| 71 |
integer :: n, step |
| 72 |
real :: x(n * step, n), y(n * step) |
| 73 |
do i = 1, n |
| 74 |
do j = 1, n |
| 75 |
x(j * step, i) = 100 |
| 76 |
end do |
| 77 |
y(i * step) = 200 |
| 78 |
end do |
| 79 |
end subroutine f8 |
| 80 |
|
| 81 |
subroutine f9(x, n, limit, step) |
| 82 |
integer :: n, limit, step |
| 83 |
real :: x(limit, n), y(limit) |
| 84 |
do i = 1, n |
| 85 |
do j = 1, limit, step |
| 86 |
x(j, i) = 100 |
| 87 |
end do |
| 88 |
y(i) = 200 |
| 89 |
end do |
| 90 |
end subroutine f9 |
| 91 |
|
| 92 |
! { dg-final { scan-tree-dump-times {likely to be the innermost dimension} 3 "lversion" } } |
| 93 |
! { dg-final { scan-tree-dump-times {want to version containing loop} 9 "lversion" } } |
| 94 |
! { dg-final { scan-tree-dump-times {hoisting check} 9 "lversion" } } |
| 95 |
! { dg-final { scan-tree-dump-times {versioned this loop} 9 "lversion" } } |