diff mbox series

[committed,OG10] Backport fixes for PR94690

Message ID ff7152a2-9346-abdf-431f-49cc153a5dd6@codesourcery.com
State New
Headers show
Series [committed,OG10] Backport fixes for PR94690 | expand

Commit Message

Kwok Cheung Yeung Aug. 14, 2020, 12:53 p.m. UTC
Hello

I have backported Tobias' patches for PR94690 from master to devel/omp/gcc-10. 
These are:

[Fortran] OpenMP - permit lastprivate in distribute + SIMD fixes (PR94690) 
(commit f884bef21cccc05d748fd7869cd641cbb4f6b6bb)

[Fortran] OpenMP 5 – permit more sharing clauses for SIMD (PR94690) (commit 
0ec52417fd9b3bef5227cdc9a18ff4f0247b0ea4)

Kwok
From b39d180f83a15eaf0b1a42afd4990378be8229e8 Mon Sep 17 00:00:00 2001
From: Kwok Cheung Yeung <kcy@codesourcery.com>
Date: Fri, 14 Aug 2020 05:20:39 -0700
Subject: [PATCH 2/2] =?UTF-8?q?[Fortran]=20OpenMP=205=20=E2=80=93=20permit?=
 =?UTF-8?q?=20more=20sharing=20clauses=20for=20SIMD=20(PR94690)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This is a backport from master of commit
0ec52417fd9b3bef5227cdc9a18ff4f0247b0ea4.

gcc/fortran/
	PR fortran/94690
	* openmp.c (resolve_omp_do): Permit more clauses for SIMD
	iteration variables.

gcc/testsuite/
	PR fortran/94690
	* gfortran.dg/gomp/openmp-simd-4.f90: New test.
---
 gcc/fortran/ChangeLog.omp                        |  9 ++++
 gcc/fortran/openmp.c                             | 17 +++----
 gcc/testsuite/ChangeLog.omp                      |  8 +++
 gcc/testsuite/gfortran.dg/gomp/openmp-simd-4.f90 | 65 ++++++++++++++++++++++++
 4 files changed, 88 insertions(+), 11 deletions(-)
 create mode 100644 gcc/testsuite/gfortran.dg/gomp/openmp-simd-4.f90
diff mbox series

Patch

diff --git a/gcc/fortran/ChangeLog.omp b/gcc/fortran/ChangeLog.omp
index 340a4dc..00c6be0 100644
--- a/gcc/fortran/ChangeLog.omp
+++ b/gcc/fortran/ChangeLog.omp
@@ -1,6 +1,15 @@ 
 2020-08-14  Kwok Cheung Yeung  <kcy@codesourcery.com>
 
 	Backport from mainline
+	2020-05-15  Tobias Burnus  <tobias@codesourcery.com>
+
+	PR fortran/94690
+	* openmp.c (resolve_omp_do): Permit more clauses for SIMD
+	iteration variables.
+
+2020-08-14  Kwok Cheung Yeung  <kcy@codesourcery.com>
+
+	Backport from mainline
 	2020-05-13  Tobias Burnus  <tobias@codesourcery.com>
 
 	PR fortran/94690
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 220b1a9..5c384ca 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -5868,26 +5868,21 @@  resolve_omp_do (gfc_code *code)
 		   "at %L", name, &do_code->loc);
       if (code->ext.omp_clauses)
 	for (list = 0; list < OMP_LIST_NUM; list++)
-	  if (!is_simd
+	  if (!is_simd || code->ext.omp_clauses->collapse > 1
 	      ? (list != OMP_LIST_PRIVATE && list != OMP_LIST_LASTPRIVATE)
-	      : code->ext.omp_clauses->collapse > 1
-	      ? (list != OMP_LIST_LASTPRIVATE)
-	      : (list != OMP_LIST_LINEAR))
+	      : (list != OMP_LIST_PRIVATE && list != OMP_LIST_LASTPRIVATE
+		 && list != OMP_LIST_LINEAR))
 	    for (n = code->ext.omp_clauses->lists[list]; n; n = n->next)
 	      if (dovar == n->sym)
 		{
-		  if (!is_simd)
+		  if (!is_simd || code->ext.omp_clauses->collapse > 1)
 		    gfc_error ("%s iteration variable present on clause "
 			       "other than PRIVATE or LASTPRIVATE at %L",
 			       name, &do_code->loc);
-		  else if (code->ext.omp_clauses->collapse > 1)
-		    gfc_error ("%s iteration variable present on clause "
-			       "other than LASTPRIVATE at %L",
-			       name, &do_code->loc);
 		  else
 		    gfc_error ("%s iteration variable present on clause "
-			       "other than LINEAR at %L",
-			       name, &do_code->loc);
+			       "other than PRIVATE, LASTPRIVATE or "
+			       "LINEAR at %L", name, &do_code->loc);
 		  break;
 		}
       if (i > 1)
diff --git a/gcc/testsuite/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index aba7d39..8f652f4 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,11 @@ 
+2020-08-14  Kwok Cheung Yeung  <kcy@codesourcery.com>
+
+	Backport from mainline
+	2020-05-15  Tobias Burnus  <tobias@codesourcery.com>
+
+	PR fortran/94690
+	* gfortran.dg/gomp/openmp-simd-4.f90: New test.
+
 2020-08-12  Kwok Cheung Yeung  <kcy@codesourcery.com>
 
 	* gcc.target/nvptx/sync.c: New.
diff --git a/gcc/testsuite/gfortran.dg/gomp/openmp-simd-4.f90 b/gcc/testsuite/gfortran.dg/gomp/openmp-simd-4.f90
new file mode 100644
index 0000000..4a17fb9
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/gomp/openmp-simd-4.f90
@@ -0,0 +1,65 @@ 
+! { dg-do compile }
+
+integer :: i, j, k
+integer :: x(5), y(2,5)
+
+!$omp parallel do private(i)
+do i = 1, 5
+  x(i) = 42
+end do
+
+!$omp parallel do lastprivate(i)
+do i = 1, 5
+  x(i) = 42
+end do
+
+
+!$omp simd private(i)
+do i = 1, 5
+  x(i) = 42
+end do
+
+!$omp simd linear(i)
+do i = 1, 5
+  x(i) = 42
+end do
+
+!$omp simd lastprivate(i)
+do i = 1, 5
+  x(i) = 42
+end do
+
+
+!$omp simd private(i) lastprivate(j) collapse(2)
+do i = 1, 5
+  do j = 1, 2
+    y(j, i) = 52
+  end do
+end do
+
+!$omp simd lastprivate(i) private(j) collapse(2)
+do i = 1, 5
+  do j = 1, 2
+    y(j, i) = 52
+  end do
+end do
+
+!$omp parallel do firstprivate(i)
+do i = 1, 5  ! { dg-error "PARALLEL DO iteration variable present on clause other than PRIVATE or LASTPRIVATE" }
+  x(i) = 42
+end do
+
+!$omp parallel do simd firstprivate(i)
+do i = 1, 5  ! { dg-error "PARALLEL DO SIMD iteration variable present on clause other than PRIVATE, LASTPRIVATE or LINEAR" }
+  x(i) = 42
+end do
+
+!$omp simd linear(i) collapse(2)
+do i = 1, 5  ! { dg-error "SIMD iteration variable present on clause other than PRIVATE or LASTPRIVATE" }
+  do j = 1, 2
+    y(j, i) = 52
+  end do
+end do
+
+
+end