https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83920
--- Comment #7 from Tom de Vries <vries at gcc dot gnu.org> --- (In reply to Tom de Vries from comment #6) > (In reply to Tom de Vries from comment #3) > > Likewise, reversing the if-then-else order in gemm.f90 makes the testcase > > fail on trunk without this patch. > > Minimal version: An even more minimal c version: ... /* { dg-do run } */ extern void abort (void); #define n 10 static void __attribute__((noinline)) __attribute__((noclone)) gemm (int beta, int *c) { #pragma acc parallel copy(c[0:(n * n) - 1]) num_gangs(2) #pragma acc loop gang for (int j = 0; j < n; ++j) if (beta != 1) { #pragma acc loop vector for (int i = 0; i < n; ++i) c[i + (j * n)] = 0; } } int main (void) { int c[n * n]; c[0] = 1; gemm (0.0, c); if (c[0] != 0) abort (); } ... Passes at O0, fails at O2.