From patchwork Sat Oct 10 11:49:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 528609 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2A0431402B2 for ; Sat, 10 Oct 2015 22:50:29 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=qOiH4CkJ; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=MrcVJ7oHVAQA0wmHn FQVveDqCFL6t9K8N+P8OQ1DxJN5iEeDErEKfatEJsBvXyXtP8DXJ3CkFP65h358I 1pooM8K6c/bub1bhYEq9qOtoaxYDCb6AICtAH4s8TQoW2iHLOg1/r5L+bayqjXSC JJimvt/iaCNgZVyKEmWowlvBvA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=E0n8+8iUZcSyd6o7BNY3SPM V4q4=; b=qOiH4CkJYwydhK1xoBB+7g007LyYYqh898W754NkX3ARLxm5EPkUzDX cqCAlDpVwis9Qyjf4DDPNiIV3JvJOAD7Uu9ZfWzZtNNad9jd6Qthim1whHwXAqZp EnA/c6EklxAFIEYCdDM9cfPaENu7Oo4sKBMhuJtxN/7Of62g9ZQc= Received: (qmail 127890 invoked by alias); 10 Oct 2015 11:50:23 -0000 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 Received: (qmail 127879 invoked by uid 89); 10 Oct 2015 11:50:22 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 10 Oct 2015 11:50:21 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41008) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1ZksfK-0000nn-0K for gcc-patches@gnu.org; Sat, 10 Oct 2015 07:50:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZksfE-00068h-Jk for gcc-patches@gnu.org; Sat, 10 Oct 2015 07:50:17 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:63764) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZksfE-00068X-Dl for gcc-patches@gnu.org; Sat, 10 Oct 2015 07:50:12 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1ZksfC-0000CX-AA from Tom_deVries@mentor.com ; Sat, 10 Oct 2015 04:50:10 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Sat, 10 Oct 2015 12:50:08 +0100 Subject: [PATCH, 2/5] Add missing phis in expand_omp_for_generic To: Bernd Schmidt References: <560100FF.9060904@mentor.com> <5601343C.9010104@redhat.com> <56114774.9090108@mentor.com> <561394CA.1050504@redhat.com> <5618F121.4070100@mentor.com> CC: "gcc-patches@gnu.org" From: Tom de Vries Message-ID: <5618FB46.2020903@mentor.com> Date: Sat, 10 Oct 2015 13:49:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <5618F121.4070100@mentor.com> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 On 10/10/15 13:06, Tom de Vries wrote: > OK, I'll repost with the patch split up, as follows: > > 1 Handle simple latch in expand_omp_for_generic > 2 Add missing phis in expand_omp_for_generic > 3 Handle original loop tree in expand_omp_for_generic > 4 Support DEFPARAMENUM in params.def > 5 Add param parloops-schedule Hi, this patch adds missing phis in expand_omp_for_generic. In expand_omp_for_generic, we add an outer loop around an inner loop. That means we need to: - add the necessary phis on the outer loop, and - move the loop entry value of the inner phi to the loop entry value of the outer phi Thanks, - Tom Add missing phis in expand_omp_for_generic 2015-09-10 Tom de Vries PR tree-optimization/67476 * omp-low.c (expand_omp_for_generic): Add missing phis. --- gcc/omp-low.c | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index f59a6a4..b2a93b9 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -238,6 +238,7 @@ static vec taskreg_contexts; static void scan_omp (gimple_seq *, omp_context *); static tree scan_omp_1_op (tree *, int *, void *); +static gphi *find_phi_with_arg_on_edge (tree, edge); #define WALK_SUBSTMTS \ case GIMPLE_BIND: \ @@ -6469,6 +6470,43 @@ expand_omp_for_generic (struct omp_region *region, } make_edge (l2_bb, l0_bb, EDGE_TRUE_VALUE); + if (gimple_in_ssa_p (cfun)) + { + /* Add phis to the outer loop that connect to the phis in the inner, + original loop, and move the loop entry value of the inner phi to + the loop entry value of the outer phi. */ + gphi_iterator psi; + for (psi = gsi_start_phis (l3_bb); !gsi_end_p (psi); gsi_next (&psi)) + { + source_location locus; + gphi *nphi; + gphi *exit_phi = psi.phi (); + + edge l2_to_l3 = find_edge (l2_bb, l3_bb); + tree exit_res = PHI_ARG_DEF_FROM_EDGE (exit_phi, l2_to_l3); + + basic_block latch = BRANCH_EDGE (cont_bb)->dest; + edge latch_to_l1 = find_edge (latch, l1_bb); + gphi *inner_phi + = find_phi_with_arg_on_edge (exit_res, latch_to_l1); + + tree t = gimple_phi_result (exit_phi); + tree new_res = copy_ssa_name (t, NULL); + nphi = create_phi_node (new_res, l0_bb); + + edge l0_to_l1 = find_edge (l0_bb, l1_bb); + t = PHI_ARG_DEF_FROM_EDGE (inner_phi, l0_to_l1); + locus = gimple_phi_arg_location_from_edge (inner_phi, l0_to_l1); + edge entry_to_l0 = find_edge (entry_bb, l0_bb); + add_phi_arg (nphi, t, entry_to_l0, locus); + + edge l2_to_l0 = find_edge (l2_bb, l0_bb); + add_phi_arg (nphi, exit_res, l2_to_l0, UNKNOWN_LOCATION); + + add_phi_arg (inner_phi, new_res, l0_to_l1, UNKNOWN_LOCATION); + }; + } + set_immediate_dominator (CDI_DOMINATORS, l2_bb, recompute_dominator (CDI_DOMINATORS, l2_bb)); set_immediate_dominator (CDI_DOMINATORS, l3_bb, -- 1.9.1