From patchwork Mon Dec 15 11:05:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 421085 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 423661400B7 for ; Mon, 15 Dec 2014 22:05:56 +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; q=dns; s=default; b=TVKPHFW8VKWj H7jgfy+Uh4VKML3y/jngnE5N6KwscvdvnR18iGwC7FzyQUMHLQChZD0m4JY7kbpz aUSyY8u0glS5xXJ3jO50jtrrz6dblUXoEub1ZwyWbsNiBOQ3T+KLFFplsmc0oFu1 odoi1CvKQHMB+El4WNi++4dIYmkSKIA= 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; s=default; bh=H5aTcqhl1CPHSooSVJ Jl8P5aM3s=; b=kUMlaEwk+a+8tiW3pSJVT4HORtmL4B1dMjxfvoXagMYux3qQtr h3tvUNge8Rlc4c0Ha/gkZwZWSah19/sZlX0CIbuqmUjFklSapK+eDHQ7aXQnQ1Y/ 0Zk06gJehcUYlDX8a/bgEnsaw8iRCmFU6XqB6R/yuptvDif4ESv6F6kF0= Received: (qmail 31664 invoked by alias); 15 Dec 2014 11:05:48 -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 31644 invoked by uid 89); 15 Dec 2014 11:05:46 -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, 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; Mon, 15 Dec 2014 11:05:44 +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 sBFB5gp2002716; Mon, 15 Dec 2014 03:05:42 -0800 Received: (from segher@localhost) by gcc1-power7.osuosl.org (8.14.6/8.14.6/Submit) id sBFB5ffm001358; Mon, 15 Dec 2014 03:05:41 -0800 From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [PATCH] combine: If a parallel I2 was split, do not allow a new I2 (PR64268) Date: Mon, 15 Dec 2014 03:05:37 -0800 Message-Id: <35b5f631a14f76c9305c7bfc8e8bf5fd764ec845.1418640924.git.segher@kernel.crashing.org> X-IsSubscribed: yes If combine is given a parallel I2, it splits it into separate I1 and I2 insns in some cases (one case since the beginning of time; more cases since my r218248). It gives the new I1 the same UID as the I2 already has; there is a comment that this works fine because the I1 never is added to the insn stream. When combine eventually replaces the insns with something new, it calls SET_INSN_DELETED on those it wants gone. Since r125624 (when DF was added, back in 2007) SET_INSN_DELETED uses the UID of the insn it is called for to do the deletion for dataflow. So since then, when such a split I1 is deleted, DF thinks I2 is deleted as well. This of course explodes if I2 is in fact needed (but only if that I2 still exists at the end of combine, i.e. the insn was not combined to further down; that might explain why it wasn't noticed before). This should be fixed properly, but it is somewhat involved. This patch simply disallows all combinations coming from a split parallel I2 if it needs a new I2. This fixes PR target/64268. Bootstrapped on powerpc64-linux and powerpc-linux; the fails are gone. Regtested on powerpc64-linux -m32,-m32/-mpowerpc64,-m64,-m64/-mlra. Is this okay for mainline? Segher 2014-12-15 Segher Boessenkool gcc/ * combine.c (try_combine): Don't try to split newpat if we started with I2 a PARALLEL that we split. --- gcc/combine.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gcc/combine.c b/gcc/combine.c index 8995c1d3..de2e49f 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -3471,6 +3471,17 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, if (insn_code_number < 0) insn_code_number = recog_for_combine (&newpat, i3, &new_i3_notes); + /* If we got I1 and I2 from splitting the original (parallel) I2 into two, + I1 and I2 have the same UID, which means that DF ends up deleting I2 + when it is asked to delete I1. So only allow this if we want I2 deleted, + that is, if we get only one insn as combine result; don't try to split + off a new I2 if it doesn't match yet. */ + if (i1 && insn_code_number < 0 && INSN_UID (i1) == INSN_UID (i2)) + { + undo_all (); + return 0; + } + /* 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