From: Jakub Jelinek Date: Wed, 20 Sep 2006 08:22:04 +0000 (+0200) Subject: re PR middle-end/28046 (libgomp test pr27337.C fails intermittently) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=66bb4f322eb936da1051767834df0db13502d8fb;p=gcc.git re PR middle-end/28046 (libgomp test pr27337.C fails intermittently) PR middle-end/28046 * c-omp.c (c_finish_omp_atomic): If ADDR is not simple enough, wrap it into TARGET_EXPR. * gcc.dg/gomp/atomic-10.c: New test. * g++.dg/gomp/atomic-10.C: New test. From-SVN: r117077 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f7361e3a67a..8b8fe3d546a 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2006-09-20 Jakub Jelinek + + PR middle-end/28046 + * c-omp.c (c_finish_omp_atomic): If ADDR is not simple enough, + wrap it into TARGET_EXPR. + 2006-09-20 Eric Christopher * config/i386/i386.c (x86_fisttp): Remove. diff --git a/gcc/c-omp.c b/gcc/c-omp.c index fe56824401c..0bae32140d8 100644 --- a/gcc/c-omp.c +++ b/gcc/c-omp.c @@ -116,6 +116,15 @@ c_finish_omp_atomic (enum tree_code code, tree lhs, tree rhs) if (addr == error_mark_node) return error_mark_node; addr = save_expr (addr); + if (TREE_CODE (addr) != SAVE_EXPR + && (TREE_CODE (addr) != ADDR_EXPR + || TREE_CODE (TREE_OPERAND (addr, 0)) != VAR_DECL)) + { + /* Make sure LHS is simple enough so that goa_lhs_expr_p can recognize + it even after unsharing function body. */ + tree var = create_tmp_var_raw (TREE_TYPE (addr), NULL); + addr = build4 (TARGET_EXPR, TREE_TYPE (addr), var, addr, NULL, NULL); + } lhs = build_indirect_ref (addr, NULL); /* There are lots of warnings, errors, and conversions that need to happen diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 5a7a5405b17..5c0a4f1b7e1 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-09-20 Jakub Jelinek + + PR middle-end/28046 + * gcc.dg/gomp/atomic-10.c: New test. + * g++.dg/gomp/atomic-10.C: New test. + 2006-09-20 Eric Christopher * gcc.target/i386/sse3-not-fisttp.c: New. diff --git a/gcc/testsuite/g++.dg/gomp/atomic-10.C b/gcc/testsuite/g++.dg/gomp/atomic-10.C new file mode 100644 index 00000000000..c8a25e2e384 --- /dev/null +++ b/gcc/testsuite/g++.dg/gomp/atomic-10.C @@ -0,0 +1,24 @@ +// PR middle-end/28046 +// { dg-do compile } +// { dg-options "-fopenmp -fdump-tree-gimple" } + +int a[3], b; +struct C { int x; int y; } c; + +int bar (void), *baz (void); + +void +foo (void) +{ +#pragma omp atomic + a[2] += bar (); +#pragma omp atomic + b += bar (); +#pragma omp atomic + c.y += bar (); +#pragma omp atomic + *baz () += bar (); +} + +// { dg-final { scan-tree-dump-times "__sync_fetch_and_add" 4 "gimple" { target i?86-*-* x86_64-*-* ia64-*-* powerpc*-*-* alpha*-*-* } } } +// { dg-final { cleanup-tree-dump "gimple" } } diff --git a/gcc/testsuite/gcc.dg/gomp/atomic-10.c b/gcc/testsuite/gcc.dg/gomp/atomic-10.c new file mode 100644 index 00000000000..bbb1ef052f8 --- /dev/null +++ b/gcc/testsuite/gcc.dg/gomp/atomic-10.c @@ -0,0 +1,24 @@ +/* PR middle-end/28046 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-gimple" } */ + +int a[3], b; +struct C { int x; int y; } c; + +int bar (void), *baz (void); + +void +foo (void) +{ +#pragma omp atomic + a[2] += bar (); +#pragma omp atomic + b += bar (); +#pragma omp atomic + c.y += bar (); +#pragma omp atomic + *baz () += bar (); +} + +/* { dg-final { scan-tree-dump-times "__sync_fetch_and_add" 4 "gimple" { target i?86-*-* x86_64-*-* ia64-*-* powerpc*-*-* alpha*-*-* } } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */