public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-12] Fortran/OpenMP: Fix -fopenmp-simd for 'omp assume(s)'
Date: Thu,  9 Feb 2023 15:32:45 +0000 (GMT)	[thread overview]
Message-ID: <20230209153245.4CB9C3858C50@sourceware.org> (raw)

https://gcc.gnu.org/g:12102532ff06fa54855ebd65cda49383c237fbf9

commit 12102532ff06fa54855ebd65cda49383c237fbf9
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Thu Feb 9 15:59:58 2023 +0100

    Fortran/OpenMP: Fix -fopenmp-simd for 'omp assume(s)'
    
    While 'omp assume' is enabled by -fopenmp-simd, 'omp assumes' is not;
    however, due to the way parsing works in Fortran (esp. for fixed-form
    source code), 'assumes' was parsed by 'assume' which then stumbled over
    the tailing 's'.
    
    gcc/fortran/
    
            * parse.cc (decode_omp_directive): Really ignore 'assumes' with
            -fopenmp-simd.
    
    gcc/testsuite/
    
            * gfortran.dg/gomp/openmp-simd-8.f90: New test.
    
    (cherry picked from commit ae091a44f6a477fbcf463e80fd604540cad3b37f)

Diff:
---
 gcc/fortran/ChangeLog.omp                        |  8 ++++++++
 gcc/fortran/parse.cc                             |  3 +++
 gcc/testsuite/ChangeLog.omp                      |  7 +++++++
 gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90 | 25 ++++++++++++++++++++++++
 4 files changed, 43 insertions(+)

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index a7e44234d2f..e9ed792a773 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,3 +1,11 @@
+2023-02-09  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2023-02-09  Tobias Burnus  <tobias@codesourcery.com>
+
+	* parse.cc (decode_omp_directive): Really ignore 'assumes' with
+	-fopenmp-simd.
+
 2023-02-01  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/gcc/fortran/parse.cc b/gcc/fortran/parse.cc
index b6f47d513b4..ca172ee16c9 100644
--- a/gcc/fortran/parse.cc
+++ b/gcc/fortran/parse.cc
@@ -889,6 +889,9 @@ decode_omp_directive (void)
   switch (c)
     {
     case 'a':
+      /* For -fopenmp-simd, ignore 'assumes'; note no clause starts with 's'. */
+      if (!flag_openmp && gfc_match ("assumes") == MATCH_YES)
+	break;
       matcho ("assumes", gfc_match_omp_assumes, ST_OMP_ASSUMES);
       matchs ("assume", gfc_match_omp_assume, ST_OMP_ASSUME);
       matcho ("atomic", gfc_match_omp_atomic, ST_OMP_ATOMIC);
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index f0c58e4d26a..061e5bea64b 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,10 @@
+2023-02-09  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2023-02-09  Tobias Burnus  <tobias@codesourcery.com>
+
+	* gfortran.dg/gomp/openmp-simd-8.f90: New test.
+
 2023-02-09  Thomas Schwinge  <thomas@codesourcery.com>
 
 	* gfortran.dg/gomp/allocate-4.f90: Cut.
diff --git a/gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90 b/gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90
new file mode 100644
index 00000000000..cf92abf2f9e
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/openmp-simd-8.f90
@@ -0,0 +1,25 @@
+! { dg-options "-fno-openmp -fopenmp-simd -fdump-tree-original" }
+
+! While 'omp assumes' is ignored with -fopenmp-simd,
+! 'omp assume' is processed - check that this works.
+
+module m
+  !$omp assumes no_openmp invalid_clause  ! Should get ignored
+contains
+  integer function foo()
+    foo = 5
+  end function
+end
+
+program main
+  use m
+  implicit none
+  !$omp assumes no_openmp  ! likewise ignored
+  integer :: n
+  !$omp assume holds (foo() > 0) ! should be honoured
+    n = foo()
+    if (n == 0) stop
+  !$omp end assume
+end
+
+! { dg-final { scan-tree-dump "\\.ASSUME \\(foo \\(\\) > 0\\);" "original" } }

                 reply	other threads:[~2023-02-09 15:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230209153245.4CB9C3858C50@sourceware.org \
    --to=burnus@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).