diff options
author | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-19 13:25:22 +0000 |
---|---|---|
committer | jakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-08-19 13:25:22 +0000 |
commit | b538a1ef072477f9ce47d1942a069b5c619d8814 (patch) | |
tree | 963ec6d00bf1bf89a14122150aae777bf1f6a55a | |
parent | a98c10fa821cd0cb9acbd9ea345baa505217b98a (diff) | |
download | gcc-b538a1ef072477f9ce47d1942a069b5c619d8814.tar.gz |
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.
* 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/trunk@177898 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/fortran/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/fortran/trans-expr.c | 9 | ||||
-rw-r--r-- | gcc/fortran/trans-openmp.c | 6 | ||||
-rw-r--r-- | libgomp/ChangeLog | 6 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.fortran/pr49792-1.f90 | 18 | ||||
-rw-r--r-- | libgomp/testsuite/libgomp.fortran/pr49792-2.f90 | 22 |
6 files changed, 64 insertions, 7 deletions
diff --git a/gcc/fortran/ChangeLog b/gcc/fortran/ChangeLog index b2f92622901..6b55546fc51 100644 --- a/gcc/fortran/ChangeLog +++ b/gcc/fortran/ChangeLog @@ -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-19 Mikael Morin <mikael.morin@sfr.fr> PR fortran/50071 diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c index 96510c2c294..39ad0b6e9e1 100644 --- a/gcc/fortran/trans-expr.c +++ b/gcc/fortran/trans-expr.c @@ -6137,10 +6137,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; @@ -6196,6 +6192,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); } @@ -6304,6 +6304,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); diff --git a/gcc/fortran/trans-openmp.c b/gcc/fortran/trans-openmp.c index b1f8e09a1b9..cfe8612dfc9 100644 --- a/gcc/fortran/trans-openmp.c +++ b/gcc/fortran/trans-openmp.c @@ -1764,9 +1764,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 = █ @@ -1903,6 +1900,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; } diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 63a8fe1d0ea..c5ebeb0b555 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -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-08-08 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> * config/posix95/lock.c, posix95/omp-lock.h: Remove. diff --git a/libgomp/testsuite/libgomp.fortran/pr49792-1.f90 b/libgomp/testsuite/libgomp.fortran/pr49792-1.f90 new file mode 100644 index 00000000000..cf2bb66fc89 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/pr49792-1.f90 @@ -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 index 00000000000..2101028a9c2 --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/pr49792-2.f90 @@ -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 |