https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81844

            Bug ID: 81844
           Summary: omp for loop optimized away
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: vries at gcc dot gnu.org
  Target Milestone: ---

Test-case from PR81805 comment 3, expanded to be runnable:
...
extern void abort (void);

#define N 32ULL
int a[N];

const unsigned long long c = 0x7fffffffffffffffULL;

void
f2_tpf_static32 (void)
{
  unsigned long long i;
  #pragma omp for
  for (i = c + N; i > c; i -= 1ULL)
    a[i - 1ULL - c] -= 4;
}

__attribute__((noinline, noclone)) int
test_tpf_static32 (void)
{
  int i, j, k;
  for (i = 0; i < N; i++)
    a[i] = i - 25;

  f2_tpf_static32 ();

  for (i = 0; i < N; i++)
    if (a[i] != i - 29)
      return 1;

  return 0;
}

int
main ()
{
  if (test_tpf_static32 ())
    abort ();

  return 0;
}
...

Passes with fno-openmp, fails with fopenmp.

With fopenmp, the for loop is optimized away.

Reply via email to