[Fortran] Disable front-end optimization for OpenACC atomic (PR93462)
authorTobias Burnus <tobias@codesourcery.com>
Fri, 31 Jan 2020 14:54:21 +0000 (15:54 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Fri, 31 Jan 2020 14:54:21 +0000 (15:54 +0100)
        PR fortran/93462
        * frontend-passes.c (gfc_code_walker): For EXEC_OACC_ATOMIC, set
        in_omp_atomic to true prevent front-end optimization.

        PR fortran/93462
        * gfortran.dg/goacc/atomic-1.f90: New.

gcc/fortran/ChangeLog
gcc/fortran/frontend-passes.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/goacc/atomic-1.f90 [new file with mode: 0644]

index b8f70e6140fb3ba1d171893775c9f13d65740ff0..9b17daf15f9ab409f68ad019340a46bd7c7229b1 100644 (file)
@@ -1,3 +1,9 @@
+2020-01-31  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/93462
+       * frontend-passes.c (gfc_code_walker): For EXEC_OACC_ATOMIC, set
+       in_omp_atomic to true prevent front-end optimization.
+
 2020-01-30  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>
 
        PR fortran/87103
 
 2020-01-28  Andrew Benson  <abensonca@gmail.com>
 
-        PR fortran/93461
-        * trans.h: Increase GFC_MAX_MANGLED_SYMBOL_LEN to
-        GFC_MAX_SYMBOL_LEN*3+5 to allow for inclusion of submodule name,
-        plus the "." between module and submodule names.
-        * gfortran.dg/pr93461.f90: New test.
+       PR fortran/93461
+       * trans.h: Increase GFC_MAX_MANGLED_SYMBOL_LEN to
+       GFC_MAX_SYMBOL_LEN*3+5 to allow for inclusion of submodule name,
+       plus the "." between module and submodule names.
+       * gfortran.dg/pr93461.f90: New test.
 
 2020-01-28  Andrew Benson  <abensonca@gmail.com>
 
index de11524ba14172d7d5273a6d1cfc529efd9e602e..bbe34d61c99fb237a0f53f4fa4b2986710d93f16 100644 (file)
@@ -5258,6 +5258,7 @@ gfc_code_walker (gfc_code **c, walk_code_fn_t codefn, walk_expr_fn_t exprfn,
              WALK_SUBEXPR (co->ext.dt->extra_comma);
              break;
 
+           case EXEC_OACC_ATOMIC:
            case EXEC_OMP_ATOMIC:
              in_omp_atomic = true;
              break;
index 8b1dcf238552e8a63d2ed70f1e69ee41796f2e3e..f95d2d4e0691e0d2d033a90751076ab863dac050 100644 (file)
@@ -1,3 +1,8 @@
+2020-01-31  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/93462
+       * gfortran.dg/goacc/atomic-1.f90: New.
+
 2020-01-31  Tamar Christina  <tamar.christina@arm.com>
 
        PR rtl-optimization/91838
diff --git a/gcc/testsuite/gfortran.dg/goacc/atomic-1.f90 b/gcc/testsuite/gfortran.dg/goacc/atomic-1.f90
new file mode 100644 (file)
index 0000000..579f049
--- /dev/null
@@ -0,0 +1,17 @@
+! { dg-do compile }
+!
+! PR fortran/93462
+!
+! Contributed by G. Steinmetz
+!
+program p
+   integer :: n = 1
+   integer :: a
+!$acc atomic write
+   a = f(n) - f(n)
+contains
+   integer function f(x)
+      integer, intent(in) :: x
+      f = x
+   end
+end