From patchwork Mon Aug 30 17:19:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 63099 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 84F75B70ED for ; Tue, 31 Aug 2010 03:20:16 +1000 (EST) Received: (qmail 524 invoked by alias); 30 Aug 2010 17:20:11 -0000 Received: (qmail 497 invoked by uid 22791); 30 Aug 2010 17:20:05 -0000 X-SWARE-Spam-Status: No, hits=-6.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_HI, SPF_HELO_PASS, TW_TM, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 30 Aug 2010 17:19:58 +0000 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o7UHJu1R019334 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 30 Aug 2010 13:19:56 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id o7UHJt11022858 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Mon, 30 Aug 2010 13:19:56 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id o7UHJtNR025908 for ; Mon, 30 Aug 2010 19:19:55 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id o7UHJtFK025907 for gcc-patches@gcc.gnu.org; Mon, 30 Aug 2010 19:19:55 +0200 Date: Mon, 30 Aug 2010 19:19:55 +0200 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [committed] #pragma omp atomic fixes (PR middle-end/45423) Message-ID: <20100830171955.GB1269@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-12-10) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Hi! This patch fixes a problem during gimplification of some boolean #pragma omp atomic stmts, and fixes parsing of boolean ++/-- atomic stmts in C and ++ atomic stmts in C++ (-- is disallowed by the standard). Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk. Will backport to 4.5/4.4 when I get to test it there. 2010-08-30 Jakub Jelinek PR middle-end/45423 * gimplify.c (goa_stabilize_expr): Handle TRUTH_NOT_EXPR and TRUTH_{AND,OR,XOR}_EXPR. * c-parser.c (c_parser_omp_atomic): Handle boolean {PRE,POST}_{INC,DEC}REMENT. cp/ * parser.c (cp_parser_omp_atomic): Handle boolean {PRE,POST}_INCREMENT. testsuite/ * gcc.dg/gomp/atomic-12.c: New test. * gcc.dg/gomp/atomic-13.c: New test. * gcc.dg/gomp/atomic-14.c: New test. * g++.dg/gomp/atomic-11.C: New test. * g++.dg/gomp/atomic-12.C: New test. * g++.dg/gomp/atomic-13.C: New test. * g++.dg/gomp/atomic-14.C: New test. Jakub --- gcc/gimplify.c.jj 2010-08-20 16:05:41.000000000 +0200 +++ gcc/gimplify.c 2010-08-30 11:43:53.000000000 +0200 @@ -6405,8 +6405,12 @@ goa_stabilize_expr (tree *expr_p, gimple { case TRUTH_ANDIF_EXPR: case TRUTH_ORIF_EXPR: + case TRUTH_AND_EXPR: + case TRUTH_OR_EXPR: + case TRUTH_XOR_EXPR: saw_lhs |= goa_stabilize_expr (&TREE_OPERAND (expr, 1), pre_p, lhs_addr, lhs_var); + case TRUTH_NOT_EXPR: saw_lhs |= goa_stabilize_expr (&TREE_OPERAND (expr, 0), pre_p, lhs_addr, lhs_var); break; --- gcc/c-parser.c.jj 2010-08-11 21:08:06.000000000 +0200 +++ gcc/c-parser.c 2010-08-30 13:10:27.000000000 +0200 @@ -8004,6 +8004,42 @@ c_parser_omp_atomic (location_t loc, c_p rhs = integer_one_node; break; + case COMPOUND_EXPR: + if (TREE_CODE (TREE_OPERAND (lhs, 0)) == SAVE_EXPR + && TREE_CODE (TREE_OPERAND (lhs, 1)) == COMPOUND_EXPR + && TREE_CODE (TREE_OPERAND (TREE_OPERAND (lhs, 1), 0)) == MODIFY_EXPR + && TREE_OPERAND (TREE_OPERAND (lhs, 1), 1) == TREE_OPERAND (lhs, 0) + && TREE_CODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND + (TREE_OPERAND (lhs, 1), 0), 0))) + == BOOLEAN_TYPE) + /* Undo effects of boolean_increment for post {in,de}crement. */ + lhs = TREE_OPERAND (TREE_OPERAND (lhs, 1), 0); + /* FALLTHRU */ + case MODIFY_EXPR: + if (TREE_CODE (lhs) == MODIFY_EXPR + && TREE_CODE (TREE_TYPE (TREE_OPERAND (lhs, 0))) == BOOLEAN_TYPE) + { + /* Undo effects of boolean_increment. */ + if (integer_onep (TREE_OPERAND (lhs, 1))) + { + /* This is pre or post increment. */ + rhs = TREE_OPERAND (lhs, 1); + lhs = TREE_OPERAND (lhs, 0); + code = NOP_EXPR; + break; + } + if (TREE_CODE (TREE_OPERAND (lhs, 1)) == TRUTH_NOT_EXPR + && TREE_OPERAND (lhs, 0) + == TREE_OPERAND (TREE_OPERAND (lhs, 1), 0)) + { + /* This is pre or post decrement. */ + rhs = TREE_OPERAND (lhs, 1); + lhs = TREE_OPERAND (lhs, 0); + code = NOP_EXPR; + break; + } + } + /* FALLTHRU */ default: switch (c_parser_peek_token (parser)->type) { --- gcc/cp/parser.c.jj 2010-08-20 16:05:29.000000000 +0200 +++ gcc/cp/parser.c 2010-08-30 13:22:13.000000000 +0200 @@ -22489,6 +22489,32 @@ cp_parser_omp_atomic (cp_parser *parser, rhs = integer_one_node; break; + case COMPOUND_EXPR: + if (TREE_CODE (TREE_OPERAND (lhs, 0)) == SAVE_EXPR + && TREE_CODE (TREE_OPERAND (lhs, 1)) == COMPOUND_EXPR + && TREE_CODE (TREE_OPERAND (TREE_OPERAND (lhs, 1), 0)) == MODIFY_EXPR + && TREE_OPERAND (TREE_OPERAND (lhs, 1), 1) == TREE_OPERAND (lhs, 0) + && TREE_CODE (TREE_TYPE (TREE_OPERAND (TREE_OPERAND + (TREE_OPERAND (lhs, 1), 0), 0))) + == BOOLEAN_TYPE) + /* Undo effects of boolean_increment for post {in,de}crement. */ + lhs = TREE_OPERAND (TREE_OPERAND (lhs, 1), 0); + /* FALLTHRU */ + case MODIFY_EXPR: + if (TREE_CODE (lhs) == MODIFY_EXPR + && TREE_CODE (TREE_TYPE (TREE_OPERAND (lhs, 0))) == BOOLEAN_TYPE) + { + /* Undo effects of boolean_increment. */ + if (integer_onep (TREE_OPERAND (lhs, 1))) + { + /* This is pre or post increment. */ + rhs = TREE_OPERAND (lhs, 1); + lhs = TREE_OPERAND (lhs, 0); + code = NOP_EXPR; + break; + } + } + /* FALLTHRU */ default: switch (cp_lexer_peek_token (parser->lexer)->type) { --- gcc/testsuite/gcc.dg/gomp/atomic-12.c.jj 2010-08-30 10:51:28.000000000 +0200 +++ gcc/testsuite/gcc.dg/gomp/atomic-12.c 2010-08-30 13:19:51.000000000 +0200 @@ -0,0 +1,306 @@ +/* PR middle-end/45423 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-gimple -g0" } */ +/* atomicvar should never be referenced in between the barrier and + following #pragma omp atomic_load. */ +/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ + +#ifdef __cplusplus +bool atomicvar, c; +#else +_Bool atomicvar, c; +#endif +int i, atomicvar2, c2; + +int +foo (void) +{ + #pragma omp barrier + #pragma omp atomic + atomicvar |= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar |= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar |= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar |= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar |= c; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= c; + #pragma omp barrier + #pragma omp atomic + atomicvar &= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar &= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar &= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar &= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar &= c; + #pragma omp barrier + #pragma omp atomic + atomicvar += -1; + #pragma omp barrier + #pragma omp atomic + atomicvar += 0; + #pragma omp barrier + #pragma omp atomic + atomicvar += 1; + #pragma omp barrier + #pragma omp atomic + atomicvar += 2; + #pragma omp barrier + #pragma omp atomic + atomicvar += c; + #pragma omp barrier + #pragma omp atomic + atomicvar -= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar -= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar -= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar -= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar -= c; + #pragma omp barrier + #pragma omp atomic + atomicvar *= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar *= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar *= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar *= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar *= c; + #pragma omp barrier + #pragma omp atomic + atomicvar /= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar /= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar /= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar /= c; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= i; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= i; + #pragma omp barrier + #pragma omp atomic + atomicvar++; + #pragma omp barrier + #pragma omp atomic + ++atomicvar; + #pragma omp barrier +#ifndef __cplusplus + #pragma omp atomic + atomicvar--; + #pragma omp barrier + #pragma omp atomic + --atomicvar; + #pragma omp barrier +#endif + return 0; +} + +int +bar (void) +{ + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= i; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= i; + #pragma omp barrier + #pragma omp atomic + atomicvar2++; + #pragma omp barrier + #pragma omp atomic + ++atomicvar2; + #pragma omp barrier + #pragma omp atomic + atomicvar2--; + #pragma omp barrier + #pragma omp atomic + --atomicvar2; + #pragma omp barrier + return 0; +} --- gcc/testsuite/gcc.dg/gomp/atomic-13.c.jj 2010-08-30 10:51:42.000000000 +0200 +++ gcc/testsuite/gcc.dg/gomp/atomic-13.c 2010-08-30 13:12:55.000000000 +0200 @@ -0,0 +1,9 @@ +/* PR middle-end/45423 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-gimple -g0 -O2" } */ +/* atomicvar should never be referenced in between the barrier and + following #pragma omp atomic_load. */ +/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ + +#include "atomic-12.c" --- gcc/testsuite/gcc.dg/gomp/atomic-14.c.jj 2010-08-30 13:15:34.000000000 +0200 +++ gcc/testsuite/gcc.dg/gomp/atomic-14.c 2010-08-30 13:15:27.000000000 +0200 @@ -0,0 +1,43 @@ +/* PR middle-end/45423 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +#ifdef __cplusplus +bool *baz (); +#else +_Bool *baz (); +#endif +int *bar (); + +int +foo (void) +{ + #pragma omp barrier + #pragma omp atomic + (*bar ())++; + #pragma omp barrier + #pragma omp atomic + ++(*bar ()); + #pragma omp barrier + #pragma omp atomic + (*bar ())--; + #pragma omp barrier + #pragma omp atomic + --(*bar ()); + #pragma omp barrier + #pragma omp atomic + (*baz ())++; + #pragma omp barrier + #pragma omp atomic + ++(*baz ()); +#ifndef __cplusplus + #pragma omp barrier + #pragma omp atomic + (*baz ())--; + #pragma omp barrier + #pragma omp atomic + --(*baz ()); + #pragma omp barrier +#endif + return 0; +} --- gcc/testsuite/g++.dg/gomp/atomic-11.C.jj 2010-08-30 10:54:13.000000000 +0200 +++ gcc/testsuite/g++.dg/gomp/atomic-11.C 2010-08-30 13:19:19.000000000 +0200 @@ -0,0 +1,306 @@ +/* PR middle-end/45423 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-gimple -g0" } */ +/* atomicvar should never be referenced in between the barrier and + following #pragma omp atomic_load. */ +/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ + +#ifdef __cplusplus +bool atomicvar, c; +#else +_Bool atomicvar, c; +#endif +int i, atomicvar2, c2; + +int +foo (void) +{ + #pragma omp barrier + #pragma omp atomic + atomicvar |= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar |= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar |= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar |= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar |= c; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar ^= c; + #pragma omp barrier + #pragma omp atomic + atomicvar &= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar &= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar &= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar &= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar &= c; + #pragma omp barrier + #pragma omp atomic + atomicvar += -1; + #pragma omp barrier + #pragma omp atomic + atomicvar += 0; + #pragma omp barrier + #pragma omp atomic + atomicvar += 1; + #pragma omp barrier + #pragma omp atomic + atomicvar += 2; + #pragma omp barrier + #pragma omp atomic + atomicvar += c; + #pragma omp barrier + #pragma omp atomic + atomicvar -= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar -= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar -= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar -= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar -= c; + #pragma omp barrier + #pragma omp atomic + atomicvar *= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar *= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar *= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar *= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar *= c; + #pragma omp barrier + #pragma omp atomic + atomicvar /= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar /= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar /= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar /= c; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar <<= i; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar >>= i; + #pragma omp barrier + #pragma omp atomic + atomicvar++; + #pragma omp barrier + #pragma omp atomic + ++atomicvar; + #pragma omp barrier +#ifndef __cplusplus + #pragma omp atomic + atomicvar--; + #pragma omp barrier + #pragma omp atomic + --atomicvar; + #pragma omp barrier +#endif + return 0; +} + +int +bar (void) +{ + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 |= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 ^= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 &= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 += c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 -= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 *= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= -1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 /= c2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 <<= i; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= 0; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= 1; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= 2; + #pragma omp barrier + #pragma omp atomic + atomicvar2 >>= i; + #pragma omp barrier + #pragma omp atomic + atomicvar2++; + #pragma omp barrier + #pragma omp atomic + ++atomicvar2; + #pragma omp barrier + #pragma omp atomic + atomicvar2--; + #pragma omp barrier + #pragma omp atomic + --atomicvar2; + #pragma omp barrier + return 0; +} --- gcc/testsuite/g++.dg/gomp/atomic-12.C.jj 2010-08-30 10:54:23.000000000 +0200 +++ gcc/testsuite/g++.dg/gomp/atomic-12.C 2010-08-30 13:16:18.000000000 +0200 @@ -0,0 +1,9 @@ +/* PR middle-end/45423 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp -fdump-tree-gimple -g0 -O2" } */ +/* atomicvar should never be referenced in between the barrier and + following #pragma omp atomic_load. */ +/* { dg-final { scan-tree-dump-not "barrier\[^#\]*atomicvar" "gimple" } } */ +/* { dg-final { cleanup-tree-dump "gimple" } } */ + +#include "atomic-11.C" --- gcc/testsuite/g++.dg/gomp/atomic-13.C.jj 2010-08-30 13:20:02.000000000 +0200 +++ gcc/testsuite/g++.dg/gomp/atomic-13.C 2010-08-30 13:15:27.000000000 +0200 @@ -0,0 +1,43 @@ +/* PR middle-end/45423 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ + +#ifdef __cplusplus +bool *baz (); +#else +_Bool *baz (); +#endif +int *bar (); + +int +foo (void) +{ + #pragma omp barrier + #pragma omp atomic + (*bar ())++; + #pragma omp barrier + #pragma omp atomic + ++(*bar ()); + #pragma omp barrier + #pragma omp atomic + (*bar ())--; + #pragma omp barrier + #pragma omp atomic + --(*bar ()); + #pragma omp barrier + #pragma omp atomic + (*baz ())++; + #pragma omp barrier + #pragma omp atomic + ++(*baz ()); +#ifndef __cplusplus + #pragma omp barrier + #pragma omp atomic + (*baz ())--; + #pragma omp barrier + #pragma omp atomic + --(*baz ()); + #pragma omp barrier +#endif + return 0; +} --- gcc/testsuite/g++.dg/gomp/atomic-14.C.jj 2010-08-30 13:29:13.000000000 +0200 +++ gcc/testsuite/g++.dg/gomp/atomic-14.C 2010-08-30 13:30:37.000000000 +0200 @@ -0,0 +1,19 @@ +// PR middle-end/45423 +// { dg-do compile } +// { dg-options "-fopenmp" } + +bool *baz (), atomicvar; + +int +foo (void) +{ + #pragma omp atomic + (*baz ())--; // { dg-error "invalid use of Boolean" } + #pragma omp atomic + --(*baz ()); // { dg-error "invalid use of Boolean" } + #pragma omp atomic + atomicvar--; // { dg-error "invalid use of Boolean" } + #pragma omp atomic + --atomicvar; // { dg-error "invalid use of Boolean" } + return 0; +}