(root)/
gcc-13.2.0/
libgomp/
testsuite/
libgomp.c-c++-common/
pr66199-2.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)) void
       9  f1 (long a, long b)
      10  {
      11    long d;
      12    #pragma omp target teams distribute parallel for simd default(none) firstprivate (a, b) shared(u, v, w)
      13    for (d = a; d < b; d++)
      14      u[d] = v[d] + w[d];
      15  }
      16  
      17  __attribute__((noinline, noclone)) void
      18  f2 (long a, long b, long c)
      19  {
      20    long d, e;
      21    #pragma omp target teams distribute parallel for simd default(none) firstprivate (a, b, c) shared(u, v, w) linear(d) lastprivate(e)
      22    for (d = a; d < b; d++)
      23      {
      24        u[d] = v[d] + w[d];
      25        e = c + d * 5;
      26      }
      27  }
      28  
      29  __attribute__((noinline, noclone)) void
      30  f3 (long a1, long b1, long a2, long b2)
      31  {
      32    long d1, d2;
      33    #pragma omp target teams distribute parallel for simd default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) lastprivate(d1, d2) collapse(2)
      34    for (d1 = a1; d1 < b1; d1++)
      35      for (d2 = a2; d2 < b2; d2++)
      36        u[d1 * 32 + d2] = v[d1 * 32 + d2] + w[d1 * 32 + d2];
      37  }
      38  
      39  __attribute__((noinline, noclone)) void
      40  f4 (long a1, long b1, long a2, long b2)
      41  {
      42    long d1, d2;
      43    #pragma omp target teams distribute parallel for simd default(none) firstprivate (a1, b1, a2, b2) shared(u, v, w) collapse(2)
      44    for (d1 = a1; d1 < b1; d1++)
      45      for (d2 = a2; d2 < b2; d2++)
      46        u[d1 * 32 + d2] = v[d1 * 32 + d2] + w[d1 * 32 + d2];
      47  }
      48  
      49  int
      50  main ()
      51  {
      52    f1 (0, 1024);
      53    f2 (0, 1024, 17);
      54    f3 (0, 32, 0, 32);
      55    f4 (0, 32, 0, 32);
      56    return 0;
      57  }