From patchwork Fri Nov 14 19:19:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 410991 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 353F914003E for ; Sat, 15 Nov 2014 06:22:07 +1100 (AEDT) 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:date:message-id:in-reply-to:references :in-reply-to:references; q=dns; s=default; b=IJXUqLhgQkh828S/gln zoRxN1+CJ+5TY+qq46j261NpcUpm7nP5ks2q66JXEab6zYjgSnR0Lr95ORNTq9HD 6IV1WnWGlFixOiGi2iL7cJWl1Q4L0Vatpu1JmPW2V4lyve5eM20Jq9JjFfVur2p/ eQxaijfoTlCmcgwIvi08olfk= 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:date:message-id:in-reply-to:references :in-reply-to:references; s=default; bh=+etV+B8BARY9CEcVKUCSVCYdB NA=; b=ZMkBH/0+gTLcULr4cKTYaTX9aEzfT2IoeohXSCtwycksO0Cr7v1y2Izz/ E7PLKt/tvEbPwIdbHVfBlm7TugsoZZ4YaXEGbulmED63n0RXGJDtRxsK4qPYCB4l Mtly0K59MQgRlfM87bPyaJK3ux3kJniA8POXhidZGBGRpJ0Bbg= Received: (qmail 6569 invoked by alias); 14 Nov 2014 19:21:57 -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 6506 invoked by uid 89); 14 Nov 2014 19:21:56 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: gcc1-power7.osuosl.org Received: from gcc1-power7.osuosl.org (HELO gcc1-power7.osuosl.org) (140.211.15.137) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-GCM-SHA384 encrypted) ESMTPS; Fri, 14 Nov 2014 19:21:55 +0000 Received: from gcc1-power7.osuosl.org (localhost [127.0.0.1]) by gcc1-power7.osuosl.org (8.14.6/8.14.6) with ESMTP id sAEJLr5U031683; Fri, 14 Nov 2014 11:21:53 -0800 Received: (from segher@localhost) by gcc1-power7.osuosl.org (8.14.6/8.14.6/Submit) id sAEJLqkN031221; Fri, 14 Nov 2014 11:21:52 -0800 From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [PATCH 5/5] combine: preferably delete dead SETs in PARALLELs Date: Fri, 14 Nov 2014 11:19:41 -0800 Message-Id: <6d31ccdf868ceee465d89fbc6ae80c141244f42b.1415984897.git.segher@kernel.crashing.org> In-Reply-To: References: In-Reply-To: References: X-IsSubscribed: yes If the result of combining some insns is a PARALLEL of two SETs, and that is not a recognised insn, and one of the SETs is dead, combine tries to use the remaining SET as insn. This patch changes things around so that the one SET is preferably used, not the PARALLEL. 2014-11-14 Segher Boessenkool gcc/ * combine.c (try_combine): Prefer to delete dead SETs inside a PARALLEL over keeping them. --- gcc/combine.c | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/gcc/combine.c b/gcc/combine.c index 8c7f052..d9292df 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -3318,29 +3318,25 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, RTVEC_ELT (newpat_vec_with_clobbers, i) = XVECEXP (newpat, 0, i); } - /* Is the result of combination a valid instruction? */ - insn_code_number = recog_for_combine (&newpat, i3, &new_i3_notes); + /* We have recognized nothing yet. */ + insn_code_number = -1; + + /* See if this is a PARALLEL of two SETs where one SET's destination is + a register that is unused and this isn't marked as an instruction that + might trap in an EH region. In that case, we just need the other SET. + We prefer this over the PARALLEL. - /* If the result isn't valid, see if it is a PARALLEL of two SETs where - the second SET's destination is a register that is unused and isn't - marked as an instruction that might trap in an EH region. In that case, - we just need the first SET. This can occur when simplifying a divmod - insn. We *must* test for this case here because the code below that - splits two independent SETs doesn't handle this case correctly when it - updates the register status. + This can occur when simplifying a divmod insn. We *must* test for this + case here because the code below that splits two independent SETs doesn't + handle this case correctly when it updates the register status. It's pointless doing this if we originally had two sets, one from i3, and one from i2. Combining then splitting the parallel results in the original i2 again plus an invalid insn (which we delete). The net effect is only to move instructions around, which makes - debug info less accurate. + debug info less accurate. */ - Also check the case where the first SET's destination is unused. - That would not cause incorrect code, but does cause an unneeded - insn to remain. */ - - if (insn_code_number < 0 - && !(added_sets_2 && i1 == 0) + if (!(added_sets_2 && i1 == 0) && GET_CODE (newpat) == PARALLEL && XVECLEN (newpat, 0) == 2 && GET_CODE (XVECEXP (newpat, 0, 0)) == SET @@ -3349,6 +3345,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, { rtx set0 = XVECEXP (newpat, 0, 0); rtx set1 = XVECEXP (newpat, 0, 1); + rtx oldpat = newpat; if (((REG_P (SET_DEST (set1)) && find_reg_note (i3, REG_UNUSED, SET_DEST (set1))) @@ -3375,8 +3372,15 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, if (insn_code_number >= 0) changed_i3_dest = 1; } + + if (insn_code_number < 0) + newpat = oldpat; } + /* Is the result of combination a valid instruction? */ + if (insn_code_number < 0) + insn_code_number = recog_for_combine (&newpat, i3, &new_i3_notes); + /* If we were combining three insns and the result is a simple SET with no ASM_OPERANDS that wasn't recognized, try to split it into two insns. There are two ways to do this. It can be split using a