PR target/82855
[official-gcc.git] / libgomp / testsuite / libgomp.c / simd-1.c
blob68a409786a9d24de9a635b86061930720beca00a
1 /* { dg-do run } */
2 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
3 /* { dg-additional-options "-mavx" { target avx_runtime } } */
5 extern void abort ();
6 int a[1024] __attribute__((aligned (32))) = { 1 };
7 int b[1024] __attribute__((aligned (32))) = { 1 };
8 int k, m;
9 struct U { int u; };
10 struct V { int v; };
12 __attribute__((noinline, noclone)) int
13 foo (int *p)
15 int i, s = 0;
16 struct U u;
17 struct V v;
18 #pragma omp simd aligned(a, p : 32) linear(k: m + 1) \
19 reduction(+:s) lastprivate(u, v)
20 for (i = 0; i < 1024; i++)
22 a[i] *= p[i];
23 u.u = p[i] + k;
24 k += m + 1;
25 v.v = p[i] + k;
26 s += p[i] + k;
28 if (u.u != 36 + 4 + 3 * 1023 || v.v != 36 + 4 + 3 * 1024)
29 abort ();
30 return s;
33 int
34 main ()
36 #if __SIZEOF_INT__ >= 4
37 int i;
38 k = 4;
39 m = 2;
40 for (i = 0; i < 1024; i++)
42 a[i] = i - 512;
43 b[i] = (i - 51) % 39;
45 int s = foo (b);
46 for (i = 0; i < 1024; i++)
48 if (b[i] != (i - 51) % 39
49 || a[i] != (i - 512) * b[i])
50 abort ();
52 if (k != 4 + 3 * 1024 || s != 1596127)
53 abort ();
54 #endif
55 return 0;