From dcaa067ea507d61dbd6ce3f4dc1b7c05beb68781 Mon Sep 17 00:00:00 2001 From: jakub Date: Sat, 10 Nov 2007 07:51:55 +0000 Subject: PR fortran/34020 * gimplify.c (goa_lhs_expr_p): Inside INDIRECT_REF handle unshared nops. * testsuite/libgomp.fortran/pr34020.f90: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@130069 138bc75d-0d04-0410-961f-82ee72b054a4 --- gcc/ChangeLog | 4 ++++ gcc/gimplify.c | 18 ++++++++++++++++-- libgomp/ChangeLog | 5 +++++ libgomp/testsuite/libgomp.fortran/pr34020.f90 | 19 +++++++++++++++++++ 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 libgomp/testsuite/libgomp.fortran/pr34020.f90 diff --git a/gcc/ChangeLog b/gcc/ChangeLog index ac0e088abf0..2edefc69a9b 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,9 @@ 2007-11-10 Jakub Jelinek + PR fortran/34020 + * gimplify.c (goa_lhs_expr_p): Inside INDIRECT_REF handle unshared + nops. + PR middle-end/34018 * tree-inline.h (copy_body_data): Add regimplify field. * tree-inline.c (copy_body_r): Set id->regimplify to true diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 5c11bad3a08..212a9dc1a60 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -5291,8 +5291,22 @@ goa_lhs_expr_p (tree expr, tree addr) == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (expr, 0))))) expr = TREE_OPERAND (expr, 0); - if (TREE_CODE (expr) == INDIRECT_REF && TREE_OPERAND (expr, 0) == addr) - return true; + if (TREE_CODE (expr) == INDIRECT_REF) + { + expr = TREE_OPERAND (expr, 0); + while (expr != addr + && (TREE_CODE (expr) == NOP_EXPR + || TREE_CODE (expr) == CONVERT_EXPR + || TREE_CODE (expr) == NON_LVALUE_EXPR) + && TREE_CODE (expr) == TREE_CODE (addr) + && TYPE_MAIN_VARIANT (TREE_TYPE (expr)) + == TYPE_MAIN_VARIANT (TREE_TYPE (addr))) + { + expr = TREE_OPERAND (expr, 0); + addr = TREE_OPERAND (addr, 0); + } + return expr == addr; + } if (TREE_CODE (addr) == ADDR_EXPR && expr == TREE_OPERAND (addr, 0)) return true; return false; diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 3a7d2f5d53e..08b417b9a54 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,8 @@ +2007-11-10 Jakub Jelinek + + PR fortran/34020 + * testsuite/libgomp.fortran/pr34020.f90: New test. + 2007-11-06 Jakub Jelinek PR c++/33894 diff --git a/libgomp/testsuite/libgomp.fortran/pr34020.f90 b/libgomp/testsuite/libgomp.fortran/pr34020.f90 new file mode 100644 index 00000000000..3bb14f5fe3d --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/pr34020.f90 @@ -0,0 +1,19 @@ +! PR fortran/34020 +! { dg-do run } + + subroutine atomic_add(lhs, rhs) + real lhs, rhs +!$omp atomic + lhs = rhs + lhs + end + + real lhs, rhs + integer i + lhs = 0 + rhs = 1 +!$omp parallel do num_threads(8) shared(lhs, rhs) + do i = 1, 300000 + call atomic_add(lhs, rhs) + enddo + if (lhs .ne. 300000) call abort + end -- cgit v1.2.1