]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[Fortran] Disable front-end optimization for OpenACC atomic (PR93462)
authorTobias Burnus <tobias@codesourcery.com>
Mon, 3 Feb 2020 11:09:46 +0000 (12:09 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Mon, 3 Feb 2020 11:09:46 +0000 (12:09 +0100)
Backported from mainline
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.

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 ec87cc9e6cf6d4be42735dfa98aab8dbdcdfc6e8..ca80c1bcd229afda9b61241bc2f0577f013bce78 100644 (file)
@@ -1,3 +1,12 @@
+2020-02-03  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from mainline
+       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-02-03  Tobias Burnus  <tobias@codesourcery.com>
 
        Backported from mainline
index 4bb6cbb5d74f0900be05a306b343e600d504d1ac..a6e710beb333360ccd63cba31215822a9919034c 100644 (file)
@@ -5260,6 +5260,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 0f8e75926659463e6961eb0d711303591e8a5b77..e3610fd7429f931743a1502a5231655d87a19ba9 100644 (file)
@@ -1,3 +1,11 @@
+2020-02-03  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backported from mainline
+       2020-01-31  Tobias Burnus  <tobias@codesourcery.com>
+
+       PR fortran/93462
+       * gfortran.dg/goacc/atomic-1.f90: New.
+
 2020-02-03  Tobias Burnus  <tobias@codesourcery.com>
 
        Backported from mainline
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