aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-16 22:40:32 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2018-02-16 22:40:32 +0000
commit51c6e646d40e5019e0a8df761fb1ac7e3459d4b3 (patch)
tree2928af1a64421d351d8d34be1829fa0f34927163
parent2c572f5f91e9750f6d14beb41c08bd80573d5a1f (diff)
PR fortran/84418
* trans-openmp.c (gfc_trans_omp_clauses): For OMP_CLAUSE_LINEAR_REF kind set OMP_CLAUSE_LINEAR_STEP to TYPE_SIZE_UNIT times last_step. * libgomp.fortran/pr84418-1.f90: New test. * libgomp.fortran/pr84418-2.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@257771 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/fortran/ChangeLog12
-rw-r--r--gcc/fortran/trans-openmp.c29
-rw-r--r--libgomp/ChangeLog6
-rw-r--r--libgomp/testsuite/libgomp.fortran/pr84418-1.f9026
-rw-r--r--libgomp/testsuite/libgomp.fortran/pr84418-2.f9035
5 files changed, 102 insertions, 6 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog
index 1c06bfd2f07..445b9cce222 100644
--- a/gcc/fortran/ChangeLog
+++ b/gcc/fortran/ChangeLog
@@ -1,4 +1,10 @@
-2018-02-16 Dominique d'Humieres <dominiq@gcc.gnu.org>
+2018-02-16 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/84418
+ * trans-openmp.c (gfc_trans_omp_clauses): For OMP_CLAUSE_LINEAR_REF
+ kind set OMP_CLAUSE_LINEAR_STEP to TYPE_SIZE_UNIT times last_step.
+
+2018-02-16 Dominique d'Humieres <dominiq@gcc.gnu.org>
PR fortran/84354
* decl.c (gfc_get_pdt_instance): Replace '%qs' with %qs.
@@ -390,7 +396,7 @@
* trans-io.c (get_dtio_proc): Likewise. (transfer_expr): Fix
whitespace.
-2018-01-13 Thomas Koenig <tkoenig@gcc.gnu.org>
+2018-01-13 Thomas Koenig <tkoenig@gcc.gnu.org>
PR fortran/83744
* dump-parse-tree.c (get_c_type_name): Remove extra line.
@@ -414,7 +420,7 @@
* trans-array.c (is_pointer_array): Remove unconditional return
of false for -fopenmp.
-2018-01-13 Thomas Koenig <tkoenig@gcc.gnu.org>
+2018-01-13 Thomas Koenig <tkoenig@gcc.gnu.org>
<emsr@gcc.gnu.org>
PR fortran/83803
diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c
index 4f5c3855799..795175d701a 100644
--- a/gcc/fortran/trans-openmp.c
+++ b/gcc/fortran/trans-openmp.c
@@ -1949,9 +1949,32 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp_clauses *clauses,
}
else
{
- tree type = gfc_typenode_for_spec (&n->sym->ts);
- OMP_CLAUSE_LINEAR_STEP (node)
- = fold_convert (type, last_step);
+ if (kind == OMP_CLAUSE_LINEAR_REF)
+ {
+ tree type;
+ if (n->sym->attr.flavor == FL_PROCEDURE)
+ {
+ type = gfc_get_function_type (n->sym);
+ type = build_pointer_type (type);
+ }
+ else
+ type = gfc_sym_type (n->sym);
+ if (POINTER_TYPE_P (type))
+ type = TREE_TYPE (type);
+ /* Otherwise to be determined what exactly
+ should be done. */
+ tree t = fold_convert (sizetype, last_step);
+ t = size_binop (MULT_EXPR, t,
+ TYPE_SIZE_UNIT (type));
+ OMP_CLAUSE_LINEAR_STEP (node) = t;
+ }
+ else
+ {
+ tree type
+ = gfc_typenode_for_spec (&n->sym->ts);
+ OMP_CLAUSE_LINEAR_STEP (node)
+ = fold_convert (type, last_step);
+ }
}
if (n->sym->attr.dimension || n->sym->attr.allocatable)
OMP_CLAUSE_LINEAR_ARRAY (node) = 1;
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index c33919d64d1..5e5e22f3a9f 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,9 @@
+2018-02-16 Jakub Jelinek <jakub@redhat.com>
+
+ PR fortran/84418
+ * libgomp.fortran/pr84418-1.f90: New test.
+ * libgomp.fortran/pr84418-2.f90: New test.
+
2018-02-14 Jakub Jelinek <jakub@redhat.com>
PR fortran/84313
diff --git a/libgomp/testsuite/libgomp.fortran/pr84418-1.f90 b/libgomp/testsuite/libgomp.fortran/pr84418-1.f90
new file mode 100644
index 00000000000..e56c022446c
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/pr84418-1.f90
@@ -0,0 +1,26 @@
+! PR fortran/84418
+! { dg-do run { target vect_simd_clones } }
+! { dg-options "-fno-inline" }
+! { dg-additional-options "-msse2" { target sse2_runtime } }
+! { dg-additional-options "-mavx" { target avx_runtime } }
+
+ real :: a(1024), b(1024), c(1024)
+ integer :: i
+ do i = 1, 1024
+ a(i) = 0.5 * i
+ b(i) = 1.5 * i
+ end do
+ !$omp simd
+ do i = 1, 1024
+ c(i) = foo (a(i), b(i))
+ end do
+ do i = 1, 1024
+ if (c(i).ne.(2 * i)) call abort
+ end do
+contains
+ real function foo (x, y)
+ real :: x, y
+ !$omp declare simd linear (ref (x, y))
+ foo = x + y
+ end function
+end
diff --git a/libgomp/testsuite/libgomp.fortran/pr84418-2.f90 b/libgomp/testsuite/libgomp.fortran/pr84418-2.f90
new file mode 100644
index 00000000000..a6657d18095
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/pr84418-2.f90
@@ -0,0 +1,35 @@
+! PR fortran/84418
+! { dg-do run { target vect_simd_clones } }
+! { dg-options "-fno-inline" }
+! { dg-additional-options "-msse2" { target sse2_runtime } }
+! { dg-additional-options "-mavx" { target avx_runtime } }
+
+ type p
+ integer :: i, j
+ end type
+ type(p) :: a(1024)
+ integer :: b(4,1024), c(1024)
+ integer :: i
+ do i = 1, 1024
+ a(i)%i = 2 * i
+ a(i)%j = 3 * i
+ b(1,i) = 4 * i
+ b(2,i) = 5 * i
+ b(3,i) = 6 * i
+ b(4,i) = 7 * i
+ end do
+ !$omp simd
+ do i = 1, 1024
+ c(i) = foo (a(i), b(:,i))
+ end do
+ do i = 1, 1024
+ if (c(i).ne.(6 * i)) call abort
+ end do
+contains
+ function foo (x, y)
+ type (p) :: x
+ integer :: y(4), foo
+ !$omp declare simd linear (ref (x, y))
+ foo = x%i + y(1)
+ end function
+end