1 // { dg-do run }
2 // { dg-additional-options "-msse2" { target sse2_runtime } }
3 // { dg-additional-options "-mavx" { target avx_runtime } }
4 
5 extern "C" void abort ();
6 int a[1024] __attribute__((aligned (32))) = { 1 };
7 struct S
8 {
9   int s;
SS10   S () : s (0) {}
~SS11   ~S () {}
12 };
13 #pragma omp declare reduction (+:S:omp_out.s += omp_in.s)
14 #pragma omp declare reduction (foo:S:omp_out.s += omp_in.s)
15 #pragma omp declare reduction (foo:int:omp_out += omp_in)
16 
17 __attribute__((noinline, noclone)) int
foo()18 foo ()
19 {
20   int i, u = 0;
21   S s, t;
22   #pragma omp simd aligned(a : 32) reduction(+:s) reduction(foo:t, u)
23   for (i = 0; i < 1024; i++)
24     {
25       int x = a[i];
26       s.s += x;
27       t.s += x;
28       u += x;
29     }
30   if (t.s != s.s || u != s.s)
31     abort ();
32   return s.s;
33 }
34 
35 int
main()36 main ()
37 {
38   int i;
39   for (i = 0; i < 1024; i++)
40     a[i] = (i & 31) + (i / 128);
41   int s = foo ();
42   if (s != 19456)
43     abort ();
44 }
45