Rebase.
[official-gcc.git] / libgomp / testsuite / libgomp.c / simd-5.c
blob0b6d41e635614617758de84a9b9e0fa250d60a4d
1 /* { dg-do run } */
2 /* { dg-options "-O2" } */
3 /* { dg-additional-options "-msse2" { target sse2_runtime } } */
4 /* { dg-additional-options "-mavx" { target avx_runtime } } */
6 extern void abort ();
7 int a[1024] __attribute__((aligned (32))) = { 1 };
8 struct S { int s; };
9 #pragma omp declare reduction (+:struct S:omp_out.s += omp_in.s)
10 #pragma omp declare reduction (foo:struct S:omp_out.s += omp_in.s)
11 #pragma omp declare reduction (foo:int:omp_out += omp_in)
13 __attribute__((noinline, noclone)) int
14 foo (void)
16 int i, u = 0, q = 0;
17 struct S s, t;
18 s.s = 0; t.s = 0;
19 #pragma omp simd aligned(a : 32) reduction(+:s, q) reduction(foo:t, u) \
20 safelen(1)
21 for (i = 0; i < 1024; i++)
23 int x = a[i];
24 s.s += x;
25 t.s += x;
26 u += x;
27 q++;
29 if (t.s != s.s || u != s.s || q != 1024)
30 abort ();
31 return s.s;
34 int
35 main ()
37 int i;
38 for (i = 0; i < 1024; i++)
39 a[i] = (i & 31) + (i / 128);
40 int s = foo ();
41 if (s != 19456)
42 abort ();
43 return 0;