PR rtl-optimization/77919
[official-gcc.git] / libgomp / testsuite / libgomp.c / simd-6.c
blob6daa33ee312dbeb126842805739feb43a500c9d6
1 /* PR libgomp/58482 */
2 /* { dg-do run } */
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;
17 struct S s, t;
18 s.s = 0; t.s = 0;
19 #pragma omp parallel for simd aligned(a : 32) reduction(+:s) \
20 reduction(foo:t, u)
21 for (i = 0; i < 1024; i++)
23 int x = a[i];
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;
37 for (i = 0; i < 1024; i++)
38 a[i] = (i & 31) + (i / 128);
39 int s = foo ();
40 if (s != 19456)
41 abort ();
42 return 0;