]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
backport: re PR fortran/86421 (OpenMP declare simd linear ref in module causes gfortr...
authorJakub Jelinek <jakub@redhat.com>
Fri, 12 Oct 2018 14:47:57 +0000 (16:47 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Fri, 12 Oct 2018 14:47:57 +0000 (16:47 +0200)
Backported from mainline
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.

From-SVN: r265106

gcc/fortran/ChangeLog
gcc/fortran/module.c
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/vect/pr86421.f90 [new file with mode: 0644]

index a51dfc5b1c5e5ffc531bfe9d332f5ea22783a922..0cc66bd051c18cac061ee5d04623ff5f20e7694d 100644 (file)
@@ -1,3 +1,14 @@
+2018-10-12  Jakub Jelinek  <jakub@redhat.com>
+
+       Backported from mainline
+       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.
+
 2018-09-13  Paul Thomas  <pault@gcc.gnu.org>
 
        Backported from trunk
index f6fad46ff31fef8844628e2dc75f08b32f9bb097..75c009a69041c5cc5fe7eb852e451db58bc2d8f4 100644 (file)
@@ -4018,6 +4018,9 @@ static const mstring omp_declare_simd_clauses[] =
     minit ("UNIFORM", 3),
     minit ("LINEAR", 4),
     minit ("ALIGNED", 5),
+    minit ("LINEAR_REF", 33),
+    minit ("LINEAR_VAL", 34),
+    minit ("LINEAR_UVAL", 35),
     minit (NULL, -1)
 };
 
@@ -4060,7 +4063,10 @@ mio_omp_declare_simd (gfc_namespace *ns, gfc_omp_declare_simd **odsp)
            }
          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);
            }
@@ -4101,11 +4107,20 @@ mio_omp_declare_simd (gfc_namespace *ns, gfc_omp_declare_simd **odsp)
            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;
            }
        }
     }
index be7ae42554e886af54aa0442bbc14da6c7a59469..d8a76b9b51228912fc6e5147d8a298c44ec8a820 100644 (file)
@@ -1,6 +1,11 @@
 2018-10-12  Jakub Jelinek  <jakub@redhat.com>
 
        Backported from mainline
+       2018-07-10  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/86421
+       * gfortran.dg/vect/pr86421.f90: New test.
+
        2018-07-16  Jakub Jelinek  <jakub@redhat.com>
 
        PR c++/3698
diff --git a/gcc/testsuite/gfortran.dg/vect/pr86421.f90 b/gcc/testsuite/gfortran.dg/vect/pr86421.f90
new file mode 100644 (file)
index 0000000..af40f40
--- /dev/null
@@ -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