(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.c/
pr58756.c
       1  /* PR libgomp/58756 */
       2  /* { dg-do run } */
       3  /* { dg-additional-options "-msse2" { target sse2_runtime } } */
       4  /* { dg-additional-options "-mavx" { target avx_runtime } } */
       5  
       6  extern void abort (void);
       7  int d[32 * 32];
       8  
       9  __attribute__((noinline, noclone)) int
      10  foo (int a, int b)
      11  {
      12    int j, c = 0;
      13    #pragma omp parallel for reduction(+: c)
      14      for (j = 0; j < a; j += 32)
      15        {
      16  	int l;
      17  	#pragma omp simd reduction(+: c) safelen(1)
      18  	  for (l = 0; l < b; ++l)
      19  	    c += d[j + l];
      20        }
      21    return c;
      22  }
      23  
      24  __attribute__((noinline, noclone)) int
      25  bar (int a)
      26  {
      27    int j, c = 0;
      28    #pragma omp parallel for simd reduction(+: c) safelen(1)
      29      for (j = 0; j < a; ++j)
      30        c += d[j];
      31    return c;
      32  }
      33  
      34  __attribute__((noinline)) static int
      35  baz (int a)
      36  {
      37    int j, c = 0;
      38    #pragma omp simd reduction(+: c) safelen(1)
      39      for (j = 0; j < a; ++j)
      40        c += d[j];
      41    return c;
      42  }
      43  
      44  int
      45  main ()
      46  {
      47    int i;
      48    for (i = 0; i < 32 * 32; i++)
      49      d[i] = (i & 31);
      50    if (foo (32 * 32, 32) != (31 * 32 / 2) * 32)
      51      abort ();
      52    if (bar (32 * 32) != (31 * 32 / 2) * 32)
      53      abort ();
      54    if (baz (32 * 32) != (31 * 32 / 2) * 32)
      55      abort ();
      56    return 0;
      57  }