Rebase.
[official-gcc.git] / libgomp / testsuite / libgomp.c / simd-8.c
blob13f40d583625566a6c523b5ae361af031249ac34
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[32][32] __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, j, u = 0;
17 struct S s, t;
18 s.s = 0; t.s = 0;
19 #pragma omp simd aligned(a : 32) reduction(+:s) reduction(foo:t, u) collapse(2)
20 for (i = 0; i < 32; i++)
21 for (j = 0; j < 32; j++)
23 int x = a[i][j];
24 s.s += x;
25 t.s += x;
26 u += x;
28 if (t.s != s.s || u != s.s)
29 abort ();
30 return s.s;
33 int
34 main ()
36 int i, j;
37 for (i = 0; i < 32; i++)
38 for (j = 0; j < 32; j++)
39 a[i][j] = j + (i / 4);
40 int s = foo ();
41 if (s != 19456)
42 abort ();
43 return 0;