2 // { dg-additional-options "-msse2" { target sse2_runtime } }
3 // { dg-additional-options "-mavx" { target avx_runtime } }
5 extern "C" void abort ();
6 int a[1024] __attribute__((aligned (32))) = { 1 };
7 int b[1024] __attribute__((aligned (32))) = { 1 };
8 unsigned char c[1024] __attribute__((aligned (32))) = { 1 };
10 __UINTPTR_TYPE__ u, u2, u3;
12 __attribute__((noinline, noclone)) int
15 int i, s = 0, s2 = 0, t, t2;
16 #pragma omp simd aligned(a, b, p : 32) linear(k: m + 1) reduction(+:s) \
18 for (i = 0; i < 512; i++)
26 #pragma omp simd aligned(a, b, p : 32) linear(k: m + 1) reduction(+:s2) \
27 lastprivate (t, u, u2, u3)
28 for (i = 512; i < 1024; i++)
33 u = (__UINTPTR_TYPE__) &k;
34 u2 = (__UINTPTR_TYPE__) &s2;
35 u3 = (__UINTPTR_TYPE__) &t;
39 return s + s2 + t + t2;
42 __attribute__((noinline, noclone)) long int
43 bar (int *p, long int n, long int o)
45 long int i, s = 0, s2 = 0, t, t2;
46 #pragma omp simd aligned(a, b, p : 32) linear(k: m + 1) reduction(+:s) \
48 for (i = 0; i < n; i++)
56 #pragma omp simd aligned(a, b, p : 32) linear(k: m + 1) reduction(+:s2) \
57 lastprivate (t, u, u2, u3)
58 for (i = n; i < o; i++)
63 u = (__UINTPTR_TYPE__) &k;
64 u2 = (__UINTPTR_TYPE__) &s2;
65 u3 = (__UINTPTR_TYPE__) &t;
69 return s + s2 + t + t2;
75 #if __SIZEOF_INT__ >= 4
79 for (i = 0; i < 1024; i++)
83 c[i] = (unsigned char) i;
86 for (i = 0; i < 1024; i++)
88 if (b[i] != (i - 51) % 39
89 || a[i] != (i - 512) * b[i]
90 || c[i] != (unsigned char) (i + 1))
95 || s != 1596127 + (4 + 3 * 511 + b[511]) + (4 + 3 * 1024 + b[1023]))
98 s = bar (b, 512, 1024);
99 for (i = 0; i < 1024; i++)
101 if (b[i] != (i - 51) % 39
102 || a[i] != (i - 512) * b[i]
103 || c[i] != (unsigned char) (i + 2))
107 if (k != 4 + 3 * 1024
108 || s != 1596127 + (4 + 3 * 511 + b[511]) + (4 + 3 * 1024 + b[1023]))
111 s = bar (b, 511, 1021);
112 for (i = 0; i < 1021; i++)
114 if (b[i] != (i - 51) % 39
115 || a[i] != (i - 512) * b[i]
116 || c[i] != (unsigned char) (i + 3))
120 for (i = 1021; i < 1024; i++)
121 if (b[i] != (i - 51) % 39
123 || c[i] != (unsigned char) (i + 2))
125 if (k != 4 + 3 * 1021
126 || s != 1586803 + (4 + 3 * 510 + b[510]) + (4 + 3 * 1021 + b[1020]))