Hi! My PR77500 fix apparently broke the following testcase, while atomic swaps are handled in many ways similarly to atomic writes, in this conditional which is the first one in atomic swap we actually need to look through the conversions.
Fixed thusly, bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk, queued for 9/8 backports. 2019-12-11 Jakub Jelinek <ja...@redhat.com> PR fortran/92899 * trans-openmp.c (gfc_trans_omp_atomic): For GFC_OMP_ATOMIC_SWAP, do look through conversion on expr2 if any. * testsuite/libgomp.fortran/atomic1.f90: New test. --- gcc/fortran/trans-openmp.c.jj 2019-12-09 19:50:25.580940368 +0100 +++ gcc/fortran/trans-openmp.c 2019-12-11 17:14:42.706119406 +0100 @@ -3534,7 +3534,6 @@ gfc_trans_omp_atomic (gfc_code *code) expr2 = code->expr2; if (((atomic_code->ext.omp_atomic & GFC_OMP_ATOMIC_MASK) != GFC_OMP_ATOMIC_WRITE) - && (atomic_code->ext.omp_atomic & GFC_OMP_ATOMIC_SWAP) == 0 && expr2->expr_type == EXPR_FUNCTION && expr2->value.function.isym && expr2->value.function.isym->id == GFC_ISYM_CONVERSION) --- libgomp/testsuite/libgomp.fortran/atomic1.f90.jj 2019-12-11 17:10:33.118950283 +0100 +++ libgomp/testsuite/libgomp.fortran/atomic1.f90 2019-12-11 17:09:46.324668521 +0100 @@ -0,0 +1,46 @@ +! PR fortran/92899 + +program pr92899 + real :: x = 1.0 + double precision :: y + integer(kind=4) :: z = 4 + integer(kind=8) :: w + !$omp atomic capture + y = x + x = 2.0 + !$omp end atomic + if (y /= 1.0 .or. x /= 2.0) stop 1 + !$omp atomic capture + x = y + y = 3.0 + !$omp end atomic + if (x /= 1.0 .or. y /= 3.0) stop 2 + !$omp atomic capture + w = z + z = 5 + !$omp end atomic + if (w /= 4 .or. z /= 5) stop 3 + !$omp atomic capture + z = w + w = 6 + !$omp end atomic + if (z /= 4 .or. w /= 6) stop 4 + !$omp atomic write + x = y + !$omp end atomic + if (x /= 3.0 .or. y /= 3.0) stop 5 + x = 7.0 + !$omp atomic write + y = x + !$omp end atomic + if (x /= 7.0 .or. y /= 7.0) stop 6 + !$omp atomic write + z = w + !$omp end atomic + if (z /= 6 .or. w /= 6) stop 7 + z = 8 + !$omp atomic write + w = z + !$omp end atomic + if (z /= 8 .or. w /= 8) stop 8 +end Jakub