2 ! { dg-options "-fcray-pointer" }
4 use iso_c_binding, only : c_ptr, c_ptrdiff_t, c_loc
6 subroutine foo (x, y, z, w)
7 use iso_c_binding, only : c_ptr
8 real, pointer :: x(:), y(:), w(:)
11 subroutine bar (x, y, z, w)
12 use iso_c_binding, only : c_ptr
13 real, pointer :: x(:), y(:), w(:)
18 real, allocatable :: c(:)
22 real, allocatable :: a(:)
25 real, target :: a(4096+63)
26 real, pointer :: p(:), q(:), r(:), s(:)
27 real, allocatable :: c(:)
28 integer(c_ptrdiff_t) :: o
30 o = 64 - mod (loc (a), 64)
33 p => a(o + 1:o + 1024)
34 q => a(o + 1025:o + 2048)
35 r => a(o + 2049:o + 3072)
36 s => a(o + 3073:o + 4096)
43 call foo (p, q, c_loc (r(1)), s)
45 if (p(i) /= i * i + 3 * i + 2) STOP 1
48 call bar (p, q, c_loc (r(1)), s)
50 if (p(i) /= i * i + 3 * i + 2) STOP 2
52 ! Attempt to create 64-byte aligned allocatable
54 allocate (c(1023 + i))
55 if (iand (loc (c(1)), 63) == 0) exit
57 allocate (b(i)%a(1023 + i))
58 allocate (c(1023 + i))
59 if (iand (loc (c(1)), 63) == 0) exit
62 if (allocated (c)) then
68 if (p(i) /= i * i + 5 * i + 2) STOP 3
72 subroutine foo (x, y, z, w)
73 use iso_c_binding, only : c_ptr, c_f_pointer
74 real, pointer :: x(:), y(:), w(:), p(:)
80 !$omp simd aligned (x, y : 64)
82 x(i) = x(i) * y(i) + 2.0
84 !$omp simd aligned (x, z : 64) private (p)
86 call c_f_pointer (z, p, shape=[1024])
89 !$omp simd aligned (x, ip : 64)
91 x(i) = x(i) + 2 * pt(i)
95 subroutine bar (x, y, z, w)
96 use iso_c_binding, only : c_ptr, c_f_pointer
97 real, pointer :: x(:), y(:), w(:), a(:), b(:)
106 !$omp simd aligned (a, b : 64)
108 a(i) = a(i) * b(i) + 2.0
110 !$omp simd aligned (a, c : 64)
113 real, pointer :: p(:)
114 call c_f_pointer (c, p, shape=[1024])
118 !$omp simd aligned (a, ip : 64)
120 a(i) = a(i) + 2 * pt(i)
124 subroutine baz (x, c)
125 real, pointer :: x(:)
126 real, allocatable :: c(:)
128 !$omp simd aligned (x, c : 64)