From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56378 invoked by alias); 10 Sep 2015 07:44:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 56368 invoked by uid 89); 10 Sep 2015 07:44:02 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,KAM_LAZY_DOMAIN_SECURITY,SPF_HELO_PASS,T_RP_MATCHES_RCVD autolearn=no version=3.3.2 X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Thu, 10 Sep 2015 07:44:01 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 30FDAC0AA26C for ; Thu, 10 Sep 2015 07:44:00 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-44.ams2.redhat.com [10.36.116.44]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t8A7hws7006787 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 10 Sep 2015 03:43:59 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id t8A7hv2C016971 for ; Thu, 10 Sep 2015 09:43:57 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id t8A7huEY016970 for gcc-patches@gcc.gnu.org; Thu, 10 Sep 2015 09:43:56 +0200 Date: Thu, 10 Sep 2015 07:45:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Put C DECL_EXPRs into OMP_FOR_PRE_BODY (PR c/67502) Message-ID: <20150910074356.GO1847@tucnak.redhat.com> Reply-To: Jakub Jelinek MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00639.txt.bz2 Hi! This C FE patch tweaks c_parser_omp_for_loop so that it puts for IVs declared in for loops their DECL_EXPRs into OMP_FOR_PRE_BODY so that the gimplifier can find them and avoid doing copyout for them. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk and 5 branch. 2015-09-10 Jakub Jelinek PR c/67502 * c-parser.c (c_parser_omp_for_loop): Emit DECL_EXPR stmts into OMP_FOR_PRE_BODY rather than before the loop. * c-c++-common/gomp/pr67502.c: New test. --- gcc/c/c-parser.c.jj 2015-09-09 09:24:11.000000000 +0200 +++ gcc/c/c-parser.c 2015-09-09 11:00:30.119045568 +0200 @@ -12869,7 +12869,8 @@ c_parser_omp_for_loop (location_t loc, c tree clauses, tree *cclauses) { tree decl, cond, incr, save_break, save_cont, body, init, stmt, cl; - tree declv, condv, incrv, initv, ret = NULL; + tree declv, condv, incrv, initv, ret = NULL_TREE; + tree pre_body = NULL_TREE, this_pre_body; bool fail = false, open_brace_parsed = false; int i, collapse = 1, nbraces = 0; location_t for_loc; @@ -12913,8 +12914,23 @@ c_parser_omp_for_loop (location_t loc, c { if (i > 0) vec_safe_push (for_block, c_begin_compound_stmt (true)); + this_pre_body = push_stmt_list (); c_parser_declaration_or_fndef (parser, true, true, true, true, true, NULL, vNULL); + if (this_pre_body) + { + this_pre_body = pop_stmt_list (this_pre_body); + if (pre_body) + { + tree t = pre_body; + pre_body = push_stmt_list (); + add_stmt (t); + add_stmt (this_pre_body); + pre_body = pop_stmt_list (pre_body); + } + else + pre_body = this_pre_body; + } decl = check_for_loop_decls (for_loc, flag_isoc99); if (decl == NULL) goto error_init; @@ -13109,7 +13125,7 @@ c_parser_omp_for_loop (location_t loc, c if (!fail) { stmt = c_finish_omp_for (loc, code, declv, initv, condv, - incrv, body, NULL); + incrv, body, pre_body); if (stmt) { if (cclauses != NULL --- gcc/testsuite/c-c++-common/gomp/pr67502.c.jj 2015-09-09 11:06:33.471688920 +0200 +++ gcc/testsuite/c-c++-common/gomp/pr67502.c 2015-09-09 11:07:13.341101057 +0200 @@ -0,0 +1,16 @@ +/* PR c/67502 */ +/* { dg-do compile } */ +/* { dg-options "-fopenmp" } */ +/* { dg-additional-options "-std=c99" { target c } } */ + +void bar (int, int); + +void +foo (void) +{ +#pragma omp parallel +#pragma omp for simd collapse(2) + for (int i = 0; i < 16; ++i) + for (int j = 0; j < 16; ++j) + bar (i, j); +} Jakub