From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75314 invoked by alias); 10 Sep 2015 07:52:06 -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 74452 invoked by uid 89); 10 Sep 2015 07:52:05 -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:52:04 +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 9E08BA8A for ; Thu, 10 Sep 2015 07:52:03 +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 t8A7q2l5010567 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Thu, 10 Sep 2015 03:52:03 -0400 Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id t8A7q0Bb017006 for ; Thu, 10 Sep 2015 09:52:01 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id t8A7q0RB017005 for gcc-patches@gcc.gnu.org; Thu, 10 Sep 2015 09:52:00 +0200 Date: Thu, 10 Sep 2015 07:58:00 -0000 From: Jakub Jelinek To: gcc-patches@gcc.gnu.org Subject: [PATCH] Further OpenMP linear NO_COPYOUT or lastprivate changes (PR c++/67514) Message-ID: <20150910075200.GR1847@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/msg00642.txt.bz2 Hi! Apparently in some cases with template instantiation it is hard to get all the DECL_EXPRs into OMP_FOR_PRE_BODY, I've been attempting it for a while on the C++ FE side, but it broke lots of tests. So, this instead deals with it at the gimplifier side, for combined for simd if the IV is defined inside of the for, it is to be treated as NO_COPYOUT or private instead of lastprivate. Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk and 5 branch. 2015-09-10 Jakub Jelinek PR c++/67514 * gimplify.c (gimplify_omp_for): For loop SIMD construct, if iterator is not explicitly determined, but is defined inside of the combined workshare region, handle it like if it has DECL_EXPR in OMP_FOR_PRE_BODY. * g++.dg/gomp/pr67514.C: New test. --- gcc/gimplify.c.jj 2015-09-09 09:19:53.000000000 +0200 +++ gcc/gimplify.c 2015-09-09 13:16:14.575761790 +0200 @@ -7123,13 +7123,27 @@ gimplify_omp_for (tree *expr_p, gimple_s OMP_CLAUSE_LINEAR_NO_COPYOUT (c) = 1; flags |= GOVD_LINEAR_LASTPRIVATE_NO_OUTER; } + struct gimplify_omp_ctx *outer + = gimplify_omp_ctxp->outer_context; + if (outer && !OMP_CLAUSE_LINEAR_NO_COPYOUT (c)) + { + if (outer->region_type == ORT_WORKSHARE + && outer->combined_loop) + { + n = splay_tree_lookup (outer->variables, + (splay_tree_key)decl); + if (n != NULL && (n->value & GOVD_LOCAL) != 0) + { + OMP_CLAUSE_LINEAR_NO_COPYOUT (c) = 1; + flags |= GOVD_LINEAR_LASTPRIVATE_NO_OUTER; + } + } + } + OMP_CLAUSE_DECL (c) = decl; OMP_CLAUSE_CHAIN (c) = OMP_FOR_CLAUSES (for_stmt); OMP_FOR_CLAUSES (for_stmt) = c; - omp_add_variable (gimplify_omp_ctxp, decl, flags); - struct gimplify_omp_ctx *outer - = gimplify_omp_ctxp->outer_context; if (outer && !OMP_CLAUSE_LINEAR_NO_COPYOUT (c)) { if (outer->region_type == ORT_WORKSHARE @@ -7166,9 +7180,16 @@ gimplify_omp_for (tree *expr_p, gimple_s if (outer->region_type == ORT_WORKSHARE && outer->combined_loop) { - if (outer->outer_context - && (outer->outer_context->region_type - == ORT_COMBINED_PARALLEL)) + n = splay_tree_lookup (outer->variables, + (splay_tree_key)decl); + if (n != NULL && (n->value & GOVD_LOCAL) != 0) + { + lastprivate = false; + outer = NULL; + } + else if (outer->outer_context + && (outer->outer_context->region_type + == ORT_COMBINED_PARALLEL)) outer = outer->outer_context; else if (omp_check_private (outer, decl, false)) outer = NULL; --- gcc/testsuite/g++.dg/gomp/pr67514.C.jj 2015-09-09 13:32:37.941269205 +0200 +++ gcc/testsuite/g++.dg/gomp/pr67514.C 2015-09-09 13:32:17.000000000 +0200 @@ -0,0 +1,30 @@ +// PR c++/67514 +// { dg-do compile } +// { dg-options "-fopenmp" } + +template +void +foo (T x, T y) +{ + #pragma omp parallel + #pragma omp for simd + for (T i = x; i < y; ++i) + ; + #pragma omp parallel + #pragma omp for simd collapse (2) + for (T i = x; i < y; ++i) + for (T j = x; j < y; j++) + ; +} + +void +bar (int *x, int *y) +{ + foo (x, y); +} + +void +baz (int x, int y) +{ + foo (x, y); +} Jakub