PR target/64358
[official-gcc.git] / libgomp / testsuite / libgomp.c++ / simd-4.C
blobbdfacc65264c9ca8863b0b8d332d9edffef3d477
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 "C" void abort ();
7 int a[1024] __attribute__((aligned (32))) = { 1 };
8 struct S
10   int s;
11   S () : s (0) {}
12   ~S () {}
14 #pragma omp declare reduction (+:S:omp_out.s += omp_in.s)
15 #pragma omp declare reduction (foo:S:omp_out.s += omp_in.s)
16 #pragma omp declare reduction (foo:int:omp_out += omp_in)
18 __attribute__((noinline, noclone)) int
19 foo ()
21   int i, u = 0;
22   S s, t;
23   #pragma omp simd aligned(a : 32) reduction(+:s) reduction(foo:t, u)
24   for (i = 0; i < 1024; i++)
25     {
26       int x = a[i];
27       s.s += x;
28       t.s += x;
29       u += x;
30     }
31   if (t.s != s.s || u != s.s)
32     abort ();
33   return s.s;
36 int
37 main ()
39   int i;
40   for (i = 0; i < 1024; i++)
41     a[i] = (i & 31) + (i / 128);
42   int s = foo ();
43   if (s != 19456)
44     abort ();