view libgomp/testsuite/libgomp.c++/pr69555-2.C @ 158:494b0b89df80 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 25 May 2020 18:13:55 +0900
parents 04ced10e8804
children
line wrap: on
line source

// PR libgomp/69555
// { dg-do run }

__attribute__((noinline, noclone)) void
f1 (int y)
{
  int a[y - 2];
  int (&c)[y - 2] = a;
  for (int i = 0; i < y - 2; i++)
    c[i] = i + 4;

  #pragma omp target firstprivate (c)
  {
    for (int i = 0; i < y - 2; i++)
      {
	if (c[i] != i + 4)
	  __builtin_abort ();
	c[i] = i + 9;
      }
    asm volatile ("" : : "r" (&c[0]) : "memory");
    for (int i = 0; i < y - 2; i++)
      if (c[i] != i + 9)
	__builtin_abort ();
  }
  for (int i = 0; i < y - 2; i++)
    if (c[i] != i + 4)
      __builtin_abort ();
}

__attribute__((noinline, noclone)) void
f2 (int y)
{
  int a[y - 2];
  int (&c)[y - 2] = a;
  for (int i = 0; i < y - 2; i++)
    c[i] = i + 4;

  #pragma omp target private (c)
  {
    for (int i = 0; i < y - 2; i++)
      c[i] = i + 9;
    asm volatile ("" : : "r" (&c[0]) : "memory");
    for (int i = 0; i < y - 2; i++)
      if (c[i] != i + 9)
	__builtin_abort ();
  }
  for (int i = 0; i < y - 2; i++)
    if (c[i] != i + 4)
      __builtin_abort ();
}

int
main ()
{
  f1 (6);
  f2 (6);
  return 0;
}