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

            Bug ID: 70680
           Summary: [5/6 Regression] OpenMP SIMD linear variable
                    privatized too eagerly
           Product: gcc
           Version: 5.1.0
            Status: UNCONFIRMED
          Keywords: openmp
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: amonakov at gcc dot gnu.org
  Target Milestone: ---

#include <stdio.h>
int main()
{
  int i=0;
#pragma omp task default(shared) if(0)
  {
#pragma omp simd
  for (i=0; i<100; i++)
    ;
#ifdef USE
  asm("" : : "r"(i));
#endif
  }
  printf("%d\n", i);
}

Per my understanding of the OpenMP spec, this program should always print
'100'; indeed, that is observed with gcc-4.9, but gcc-5 does not share 'i' with
the task region, unless a dummy use is injected after the openmp-simd loop:

$ gcc-4.9 -O2 -fopenmp t.c && ./a.out
100

$ gcc-5.1 -O2 -fopenmp t.c && ./a.out
0

$ gcc-5.1 -DUSE -O2 -fopenmp t.c && ./a.out
100

Reply via email to