public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
* [committed] Save/restore OpenMP linear clause modifiers in modules (PR fortran/86421)
@ 2018-07-10  7:33 Jakub Jelinek
  0 siblings, 0 replies; only message in thread
From: Jakub Jelinek @ 2018-07-10  7:33 UTC (permalink / raw)
  To: gcc-patches; +Cc: fortran

Hi!

This patch (in a backwards compatible way) handles saving and restoring of
linear clause modifiers.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

2018-07-10  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/86421
	* module.c (omp_declare_simd_clauses): Add LINEAR with _REF, _VAL and
	_UVAL suffixes.
	(mio_omp_declare_simd): Save and restore ref, val and uval modifiers
	on linear clauses.  Initialize n->where to gfc_current_locus.

	* gfortran.dg/vect/pr86421.f90: New test.

--- gcc/fortran/module.c.jj	2018-02-13 09:28:10.000000000 +0100
+++ gcc/fortran/module.c	2018-07-09 18:56:49.595348962 +0200
@@ -4098,6 +4098,9 @@ static const mstring omp_declare_simd_cl
     minit ("UNIFORM", 3),
     minit ("LINEAR", 4),
     minit ("ALIGNED", 5),
+    minit ("LINEAR_REF", 33),
+    minit ("LINEAR_VAL", 34),
+    minit ("LINEAR_UVAL", 35),
     minit (NULL, -1)
 };
 
@@ -4140,7 +4143,10 @@ mio_omp_declare_simd (gfc_namespace *ns,
 	    }
 	  for (n = ods->clauses->lists[OMP_LIST_LINEAR]; n; n = n->next)
 	    {
-	      mio_name (4, omp_declare_simd_clauses);
+	      if (n->u.linear_op == OMP_LINEAR_DEFAULT)
+		mio_name (4, omp_declare_simd_clauses);
+	      else
+		mio_name (32 + n->u.linear_op, omp_declare_simd_clauses);
 	      mio_symbol_ref (&n->sym);
 	      mio_expr (&n->expr);
 	    }
@@ -4181,11 +4187,20 @@ mio_omp_declare_simd (gfc_namespace *ns,
 	    case 4:
 	    case 5:
 	      *ptrs[t - 3] = n = gfc_get_omp_namelist ();
+	    finish_namelist:
+	      n->where = gfc_current_locus;
 	      ptrs[t - 3] = &n->next;
 	      mio_symbol_ref (&n->sym);
 	      if (t != 3)
 		mio_expr (&n->expr);
 	      break;
+	    case 33:
+	    case 34:
+	    case 35:
+	      *ptrs[1] = n = gfc_get_omp_namelist ();
+	      n->u.linear_op = (enum gfc_omp_linear_op) (t - 32);
+	      t = 4;
+	      goto finish_namelist;
 	    }
 	}
     }
--- gcc/testsuite/gfortran.dg/vect/pr86421.f90.jj	2018-07-09 19:09:56.662398875 +0200
+++ gcc/testsuite/gfortran.dg/vect/pr86421.f90	2018-07-09 19:07:57.432240946 +0200
@@ -0,0 +1,35 @@
+! PR fortran/86421
+! { dg-require-effective-target vect_simd_clones }
+! { dg-additional-options "-fopenmp-simd" }
+! { dg-additional-options "-mavx" { target avx_runtime } }
+
+module mod86421
+  implicit none
+contains
+  subroutine foo(x, y, z)
+    real :: x
+    integer :: y, z
+    !$omp declare simd linear(ref(x)) linear(val(y)) linear(uval(z))
+    x = x + y
+    z = z + 1
+  end subroutine
+end module mod86421
+
+program pr86421
+  use mod86421
+  implicit none
+  integer :: i, j
+  real :: a(64)
+  j = 0
+  do i = 1, 64
+    a(i) = i
+  end do
+  !$omp simd
+  do i = 1, 64
+    call foo (a(i), i, j)
+  end do
+  do i = 1, 64
+    if (a(i) .ne. (2 * i)) stop 1
+  end do
+  if (j .ne. 64) stop 2
+end program pr86421

	Jakub

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-07-10  7:33 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-10  7:33 [committed] Save/restore OpenMP linear clause modifiers in modules (PR fortran/86421) Jakub Jelinek

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).