(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.c-c++-common/
pr66199-9.c
       1  /* PR middle-end/66199 */
       2  /* { dg-do run } */
       3  
       4  #pragma omp declare target
       5  int u[1024], v[1024], w[1024];
       6  #pragma omp end declare target
       7  
       8  __attribute__((noinline, noclone)) long
       9  f2 (long a, long b, long c)
      10  {
      11    long d, e;
      12    #pragma omp target map(from: d, e)
      13    #pragma omp teams default(none) firstprivate (a, b, c) shared(d, e, u, v, w)
      14    #pragma omp distribute lastprivate(d, e)
      15    for (d = a; d < b; d++)
      16      {
      17        u[d] = v[d] + w[d];
      18        e = c + d * 5;
      19      }
      20    return d + e;
      21  }
      22  
      23  __attribute__((noinline, noclone)) long
      24  f3 (long a1, long b1, long a2, long b2)
      25  {
      26    long d1, d2;
      27    #pragma omp target map(from: d1, d2)
      28    #pragma omp teams default(none) shared(a1, b1, a2, b2, d1, d2, u, v, w)
      29    #pragma omp distribute firstprivate (a1, b1, a2, b2) lastprivate(d1, d2) collapse(2)
      30    for (d1 = a1; d1 < b1; d1++)
      31      for (d2 = a2; d2 < b2; d2++)
      32        u[d1 * 32 + d2] = v[d1 * 32 + d2] + w[d1 * 32 + d2];
      33    return d1 + d2;
      34  }
      35  
      36  int
      37  main ()
      38  {
      39    if (f2 (0, 1024, 17) != 1024 + (17 + 5 * 1023)
      40        || f3 (0, 32, 0, 32) != 64)
      41      __builtin_abort ();
      42    return 0;
      43  }