Hi!

On 2015-11-03T12:30:09+0100, I wrote:
> On Mon, 2 Nov 2015 14:40:54 +0100, Jakub Jelinek <ja...@redhat.com> wrote:
>> On Mon, Nov 02, 2015 at 02:09:38PM +0100, Thomas Schwinge wrote:
>> > The OpenACC atomic directive matches OpenMP's atomic directive (got that
>> > clarified by the OpenACC committee), so they can share the same
>> > implementation.

> [...], committed in r229703:

> --- gcc/omp-low.c
> +++ gcc/omp-low.c
> @@ -3212,7 +3212,10 @@ check_omp_nesting_restrictions (gimple *stmt, 
> omp_context *ctx)
|    /* No nesting of non-OpenACC STMT (that is, an OpenMP one, or a GOMP 
builtin)
|       inside an OpenACC CTX.  */
|    if (!(is_gimple_omp (stmt)
|         && is_gimple_omp_oacc (stmt)))
>      {
>        for (omp_context *ctx_ = ctx; ctx_ != NULL; ctx_ = ctx_->outer)
>       if (is_gimple_omp (ctx_->stmt)
> -         && is_gimple_omp_oacc (ctx_->stmt))
> +         && is_gimple_omp_oacc (ctx_->stmt)
> +         /* Except for atomic codes that we share with OpenMP.  */
> +         && ! (gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
> +               || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE))
>         {
>           error_at (gimple_location (stmt),
>                     "non-OpenACC construct inside of OpenACC region");

(The 'gimple_code (stmt) == [...]' expressions later got hoisted out of
the 'ctx_' loop.)

As came up in a different context, it's actually conceptually clearer to
make sure that 'is_gimple_omp_oacc' isn't even used for such "ambiguous"
codes, and here appears to be the only place we do.  Pushed "[OMP]
Tighten 'is_gimple_omp_oacc'" to master branch in commit
e1cca88019ab1208f8389606dd18a25cd50c20e1, see attached.


Grüße
 Thomas


-----------------
Mentor Graphics (Deutschland) GmbH, Arnulfstrasse 201, 80634 München 
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Frank 
Thürauf
>From e1cca88019ab1208f8389606dd18a25cd50c20e1 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <tho...@codesourcery.com>
Date: Fri, 7 May 2021 10:13:49 +0200
Subject: [PATCH] [OMP] Tighten 'is_gimple_omp_oacc'

No overall change in behavior.

	gcc/
	* gimple.h (is_gimple_omp_oacc): Tighten.
	* omp-low.c (check_omp_nesting_restrictions): Adjust.
---
 gcc/gimple.h  |  8 ++++++++
 gcc/omp-low.c | 11 ++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/gcc/gimple.h b/gcc/gimple.h
index 3ec86f5f082..91b92b4a4d1 100644
--- a/gcc/gimple.h
+++ b/gcc/gimple.h
@@ -6501,6 +6501,14 @@ is_gimple_omp_oacc (const gimple *stmt)
   gcc_assert (is_gimple_omp (stmt));
   switch (gimple_code (stmt))
     {
+    case GIMPLE_OMP_ATOMIC_LOAD:
+    case GIMPLE_OMP_ATOMIC_STORE:
+    case GIMPLE_OMP_CONTINUE:
+    case GIMPLE_OMP_RETURN:
+      /* Codes shared between OpenACC and OpenMP cannot be used to disambiguate
+	 the two.  */
+      gcc_unreachable ();
+
     case GIMPLE_OMP_FOR:
       switch (gimple_omp_for_kind (stmt))
 	{
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index cadca7e201f..d1136d181b3 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -3016,11 +3016,12 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx)
 
   /* No nesting of non-OpenACC STMT (that is, an OpenMP one, or a GOMP builtin)
      inside an OpenACC CTX.  */
-  if (!(is_gimple_omp (stmt)
-	&& is_gimple_omp_oacc (stmt))
-      /* Except for atomic codes that we share with OpenMP.  */
-      && !(gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
-	   || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE))
+  if (gimple_code (stmt) == GIMPLE_OMP_ATOMIC_LOAD
+      || gimple_code (stmt) == GIMPLE_OMP_ATOMIC_STORE)
+    /* ..., except for the atomic codes that OpenACC shares with OpenMP.  */
+    ;
+  else if (!(is_gimple_omp (stmt)
+	     && is_gimple_omp_oacc (stmt)))
     {
       if (oacc_get_fn_attrib (cfun->decl) != NULL)
 	{
-- 
2.30.2

Reply via email to