From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 96315 invoked by alias); 15 Apr 2015 13:17:41 -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 96302 invoked by uid 89); 15 Apr 2015 13:17:41 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 15 Apr 2015 13:17:40 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-03.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1YiNCC-0005MQ-ER from Tom_deVries@mentor.com ; Wed, 15 Apr 2015 06:17:36 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-03.mgc.mentorg.com (137.202.0.108) with Microsoft SMTP Server id 14.3.224.2; Wed, 15 Apr 2015 14:17:34 +0100 Message-ID: <552E64EC.5060707@mentor.com> Date: Wed, 15 Apr 2015 13:17:00 -0000 From: Tom de Vries User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: Jakub Jelinek CC: GCC Patches Subject: [PR65637][PATCH][2/3] Fix inner loop phi in expand_omp_for_static_chunk References: <552E6341.4040401@mentor.com> In-Reply-To: <552E6341.4040401@mentor.com> Content-Type: multipart/mixed; boundary="------------080202060601020408030900" X-SW-Source: 2015-04/txt/msg00759.txt.bz2 --------------080202060601020408030900 Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 7bit Content-length: 1622 On 15-04-15 15:10, Tom de Vries wrote: > Hi, > > This patch series fixes PR65637. > > Currently, ssa-handling code in expand_omp_for_static_chunk is dead and not > exercised by testing. > > Ssa-handling code in omp-low.c is only triggered by pass_parallelize_loops, and > that pass doesn't specify a chunk size on the GIMPLE_OMP_FOR it constructs, so > that only exercises the expand_omp_for_static_nochunk path. > > Using the attached trigger patch, we excercise the ssa-handling code in > expand_omp_for_static_chunk. The following patch series fixes the problems in > the ssa-handling code that we encounter. > > 1. Fix gcc_assert in expand_omp_for_static_chunk > 2. Fix inner loop phi in expand_omp_for_static_chunk > 3. Handle 2 preds for fin_bb in expand_omp_for_static_chunk > > The patch series has been bootstrapped and reg-tested on x86_64 together with > attached trigger patch. > > I'll post the patches from the patch series individually, in response to this > email. > This patch fixes an libgomp.c/autopar-1.c execution failure. For autopar-1.c, the original loop has a loop phi: ... # s.5_20 = PHI ... After expand_omp_for_static_chunk, there's an inner and an outer loop. The outer loop phi is: ... # s.5_11 = PHI <0.0(15), s.5_12(21)> ... and the inner loop phi is: ... # s.5_20 = PHI ... The inner loop phi should not have 0.0 as argument, but the result of the outer loop phi, like this: ... # s.5_20 = PHI ... This patch fixes the inner loop phi, and allows the autopar-1.c execution test to pass. OK for trunk? Thanks, - Tom --------------080202060601020408030900 Content-Type: text/x-patch; name="0003-Fix-inner-loop-phi-in-expand_omp_for_static_chunk.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0003-Fix-inner-loop-phi-in-expand_omp_for_static_chunk.patch" Content-length: 1747 Fix inner loop phi in expand_omp_for_static_chunk 2015-04-15 Tom de Vries PR tree-optimization/65637 * omp-low.c (find_phi_with_arg_on_edge): New function. (expand_omp_for_static_chunk): Fix inner loop phi. --- gcc/omp-low.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index f7b9d11..62cbed0 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -6844,6 +6844,22 @@ expand_omp_for_static_nochunk (struct omp_region *region, } } +static gphi * +find_phi_with_arg_on_edge (tree arg, edge e) +{ + basic_block bb = e->dest; + + for (gphi_iterator gpi = gsi_start_phis (bb); + !gsi_end_p (gpi); + gsi_next (&gpi)) + { + gphi *phi = gpi.phi (); + if (PHI_ARG_DEF_FROM_EDGE (phi, e) == arg) + return phi; + } + + return NULL; +} /* A subroutine of expand_omp_for. Generate code for a parallel loop with static schedule and a specified chunk size. Given @@ -7272,7 +7288,14 @@ expand_omp_for_static_chunk (struct omp_region *region, t = vextra; add_phi_arg (nphi, t, ene, locus); locus = redirect_edge_var_map_location (vm); - add_phi_arg (nphi, redirect_edge_var_map_def (vm), re, locus); + tree back_arg = redirect_edge_var_map_def (vm); + add_phi_arg (nphi, back_arg, re, locus); + gphi *inner_loop_phi + = find_phi_with_arg_on_edge (back_arg, + find_edge (cont_bb, body_bb)); + gcc_assert (inner_loop_phi != NULL); + add_phi_arg (inner_loop_phi, gimple_phi_result (nphi), + find_edge (seq_start_bb, body_bb), locus); } gcc_assert (gsi_end_p (psi) && (head == NULL || i == head->length ())); redirect_edge_var_map_clear (re); -- 1.9.1 --------------080202060601020408030900--