From patchwork Fri Oct 30 18:02:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 538462 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 7C9AD140D9D for ; Sat, 31 Oct 2015 05:03:20 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=tw5+FQsH; 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:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; q=dns; s=default; b=VShYCW/hG15or/hu L6ye+MlvX+yluuBGuvZTGUst8jjKe9tGCNRW4uK52VcjRatyu34SFE/X+2/GQAtu RiU/phzZZPtxl7GP+UrrX1OGLT3a4ds0fCU4oOX4aqYhu4zG0vxJaB+3EUEnXIeN SBvmNKxUXtZtFXDVmDJqJOd6RVA= 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:from :to:cc:subject:references:date:in-reply-to:message-id :mime-version:content-type; s=default; bh=/hIVhC9IgRJoWRH8aMmLnp OlJDs=; b=tw5+FQsHGq+ZhTYgjn+ndOeZZemX7reUyuJpTJGVGc1A9yQbzab52C FWEkI6THiD9wuEKcDa1bqIq7zskSVsfxy0l11N9j1DWGtblX6ZNyjOrFuZWMlsP0 IV5lEwfkF0COpB2NXUiRF/xCBWcaOGKTRhPfPv1KVgVWTGsvnXBRc= Received: (qmail 126243 invoked by alias); 30 Oct 2015 18:03:13 -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 126220 invoked by uid 89); 30 Oct 2015 18:03:12 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-3.2 required=5.0 tests=AWL, BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham 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; Fri, 30 Oct 2015 18:03:11 +0000 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by mx1.redhat.com (Postfix) with ESMTPS id 6364A3A1182; Fri, 30 Oct 2015 18:03:10 +0000 (UTC) Received: from freie.home (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t9UI38a2030119 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 30 Oct 2015 14:03:09 -0400 Received: from livre.home (livre.home [172.31.160.2]) by freie.home (8.14.9/8.14.9) with ESMTP id t9UI2wnO030528; Fri, 30 Oct 2015 16:02:58 -0200 From: Alexandre Oliva To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [PR68083] stop ifcombine from moving uninitialized uses before their guards References: Date: Fri, 30 Oct 2015 16:02:58 -0200 In-Reply-To: (Alexandre Oliva's message of "Fri, 30 Oct 2015 11:41:14 -0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 On Oct 30, 2015, Alexandre Oliva wrote: > Incidentally, bb_no_side_effects_p (inner_cond_bb) is called in all four > tests in tree_ssa_ifcombine_bb_1, for each outer_cond_bb that > tree_ssa_ifcombine_bb might choose. Is there any reason to not factor > it out to the test that checks whether the inner_cond_bb is indeed an > if_then_else block, early in tree_ssa_ifcombine_bb, so as to > short-circuit the whole thing when the inner block is not viable? Like this... Bail out early if the inner block has side effects or is otherwise not eligible for ifcombine. Regstrapped on x86_64-linux-gnu. Ok to install? for gcc/ChangeLog * tree-ssa-ifcombine.c (tree_ssa_ifcombine_bb_1): Factor out bb_no_side_effects_p tests... (tree_ssa_ifcombine_bb): ... here. --- gcc/tree-ssa-ifcombine.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/gcc/tree-ssa-ifcombine.c b/gcc/tree-ssa-ifcombine.c index 622dc6b..3b60968 100644 --- a/gcc/tree-ssa-ifcombine.c +++ b/gcc/tree-ssa-ifcombine.c @@ -579,8 +579,7 @@ tree_ssa_ifcombine_bb_1 (basic_block inner_cond_bb, basic_block outer_cond_bb, the inner cond_bb having no side-effects. */ if (phi_pred_bb != else_bb && recognize_if_then_else (outer_cond_bb, &inner_cond_bb, &else_bb) - && same_phi_args_p (outer_cond_bb, phi_pred_bb, else_bb) - && bb_no_side_effects_p (inner_cond_bb)) + && same_phi_args_p (outer_cond_bb, phi_pred_bb, else_bb)) { /* We have @@ -598,8 +597,7 @@ tree_ssa_ifcombine_bb_1 (basic_block inner_cond_bb, basic_block outer_cond_bb, /* And a version where the outer condition is negated. */ if (phi_pred_bb != else_bb && recognize_if_then_else (outer_cond_bb, &else_bb, &inner_cond_bb) - && same_phi_args_p (outer_cond_bb, phi_pred_bb, else_bb) - && bb_no_side_effects_p (inner_cond_bb)) + && same_phi_args_p (outer_cond_bb, phi_pred_bb, else_bb)) { /* We have @@ -620,8 +618,7 @@ tree_ssa_ifcombine_bb_1 (basic_block inner_cond_bb, basic_block outer_cond_bb, having no side-effects. */ if (phi_pred_bb != then_bb && recognize_if_then_else (outer_cond_bb, &then_bb, &inner_cond_bb) - && same_phi_args_p (outer_cond_bb, phi_pred_bb, then_bb) - && bb_no_side_effects_p (inner_cond_bb)) + && same_phi_args_p (outer_cond_bb, phi_pred_bb, then_bb)) { /* We have @@ -638,8 +635,7 @@ tree_ssa_ifcombine_bb_1 (basic_block inner_cond_bb, basic_block outer_cond_bb, /* And a version where the outer condition is negated. */ if (phi_pred_bb != then_bb && recognize_if_then_else (outer_cond_bb, &inner_cond_bb, &then_bb) - && same_phi_args_p (outer_cond_bb, phi_pred_bb, then_bb) - && bb_no_side_effects_p (inner_cond_bb)) + && same_phi_args_p (outer_cond_bb, phi_pred_bb, then_bb)) { /* We have @@ -676,7 +672,8 @@ tree_ssa_ifcombine_bb (basic_block inner_cond_bb) if (a && b) ; This requires a single predecessor of the inner cond_bb. */ - if (single_pred_p (inner_cond_bb)) + if (single_pred_p (inner_cond_bb) + && bb_no_side_effects_p (inner_cond_bb)) { basic_block outer_cond_bb = single_pred (inner_cond_bb);