OSDN Git Service

PR fortran/49792
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Aug 2011 13:26:50 +0000 (13:26 +0000)
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 19 Aug 2011 13:26:50 +0000 (13:26 +0000)
* trans-expr.c (gfc_trans_assignment_1): Set OMPWS_SCALARIZER_WS
bit in ompws_flags only if loop.temp_ss is NULL, and clear it if
lhs needs reallocation.
* trans-openmp.c (gfc_trans_omp_workshare): Don't return early if
code is NULL, emit a barrier if workshare emitted no code at all
and NOWAIT clause isn't present.

* testsuite/libgomp.fortran/pr49792-1.f90: New test.
* testsuite/libgomp.fortran/pr49792-2.f90: New test.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_6-branch@177900 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/fortran/ChangeLog
gcc/fortran/trans-expr.c
gcc/fortran/trans-openmp.c
libgomp/ChangeLog
libgomp/testsuite/libgomp.fortran/pr49792-1.f90 [new file with mode: 0644]
libgomp/testsuite/libgomp.fortran/pr49792-2.f90 [new file with mode: 0644]

index e38fd2b..a9828cf 100644 (file)
@@ -1,3 +1,13 @@
+2011-08-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/49792
+       * trans-expr.c (gfc_trans_assignment_1): Set OMPWS_SCALARIZER_WS
+       bit in ompws_flags only if loop.temp_ss is NULL, and clear it if
+       lhs needs reallocation.
+       * trans-openmp.c (gfc_trans_omp_workshare): Don't return early if
+       code is NULL, emit a barrier if workshare emitted no code at all
+       and NOWAIT clause isn't present.
+
 2011-08-05  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/49112
index 0487f75..964766e 100644 (file)
@@ -6033,10 +6033,6 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
   rss = NULL;
   if (lss != gfc_ss_terminator)
     {
-      /* Allow the scalarizer to workshare array assignments.  */
-      if (ompws_flags & OMPWS_WORKSHARE_FLAG)
-       ompws_flags |= OMPWS_SCALARIZER_WS;
-
       /* The assignment needs scalarization.  */
       lss_section = lss;
 
@@ -6092,6 +6088,10 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
          gfc_mark_ss_chain_used (loop.temp_ss, 3);
        }
 
+      /* Allow the scalarizer to workshare array assignments.  */
+      if ((ompws_flags & OMPWS_WORKSHARE_FLAG) && loop.temp_ss == NULL)
+       ompws_flags |= OMPWS_SCALARIZER_WS;
+
       /* Start the scalarized loop body.  */
       gfc_start_scalarized_body (&loop, &body);
     }
@@ -6200,6 +6200,7 @@ gfc_trans_assignment_1 (gfc_expr * expr1, gfc_expr * expr2, bool init_flag,
            && !gfc_expr_attr (expr1).codimension
            && !gfc_is_coindexed (expr1))
        {
+         ompws_flags &= ~OMPWS_SCALARIZER_WS;
          tmp = gfc_alloc_allocatable_for_assignment (&loop, expr1, expr2);
          if (tmp != NULL_TREE)
            gfc_add_expr_to_block (&loop.code[expr1->rank - 1], tmp);
index 53eb999..733bd10 100644 (file)
@@ -1640,9 +1640,6 @@ gfc_trans_omp_workshare (gfc_code *code, gfc_omp_clauses *clauses)
 
   pushlevel (0);
 
-  if (!code)
-    return build_empty_stmt (input_location);
-
   gfc_start_block (&block);
   pblock = &block;
 
@@ -1779,6 +1776,9 @@ gfc_trans_omp_workshare (gfc_code *code, gfc_omp_clauses *clauses)
   else
     poplevel (0, 0, 0);
 
+  if (IS_EMPTY_STMT (stmt) && !clauses->nowait)
+    stmt = gfc_trans_omp_barrier ();
+
   ompws_flags = 0;
   return stmt;
 }
index ecc08e8..0f635c5 100644 (file)
@@ -1,3 +1,9 @@
+2011-08-19  Jakub Jelinek  <jakub@redhat.com>
+
+       PR fortran/49792
+       * testsuite/libgomp.fortran/pr49792-1.f90: New test.
+       * testsuite/libgomp.fortran/pr49792-2.f90: New test.
+
 2011-07-29  Jakub Jelinek  <jakub@redhat.com>
 
        PR middle-end/49897
diff --git a/libgomp/testsuite/libgomp.fortran/pr49792-1.f90 b/libgomp/testsuite/libgomp.fortran/pr49792-1.f90
new file mode 100644 (file)
index 0000000..cf2bb66
--- /dev/null
@@ -0,0 +1,18 @@
+! PR fortran/49792
+! { dg-do run }
+
+subroutine reverse(n, a)
+  integer :: n
+  real(kind=8) :: a(n)
+!$omp parallel workshare
+  a(:) = a(n:1:-1)
+!$omp end parallel workshare
+end subroutine reverse
+
+program pr49792
+  real(kind=8) :: a(16) = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
+  real(kind=8) :: b(16)
+  b(:) = a(16:1:-1)
+  call reverse (16,a)
+  if (any (a.ne.b)) call abort
+end program pr49792
diff --git a/libgomp/testsuite/libgomp.fortran/pr49792-2.f90 b/libgomp/testsuite/libgomp.fortran/pr49792-2.f90
new file mode 100644 (file)
index 0000000..2101028
--- /dev/null
@@ -0,0 +1,22 @@
+! PR fortran/49792
+! { dg-do run }
+! { dg-options "-std=f2003 -fall-intrinsics" }
+
+subroutine reverse(n, a)
+  integer :: n
+  real(kind=8) :: a(n)
+!$omp parallel workshare
+  a(:) = a(n:1:-1)
+!$omp end parallel workshare
+end subroutine reverse
+
+program pr49792
+  integer :: b(16)
+  integer, allocatable :: a(:)
+  b = 1
+!$omp parallel workshare
+  a = b
+!$omp end parallel workshare
+  if (size(a).ne.size(b)) call abort()
+  if (any (a.ne.b)) call abort()
+end program pr49792