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