From patchwork Fri Nov 17 14:43:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Segher Boessenkool X-Patchwork-Id: 839023 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-467142-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="TXCgbyNm"; dkim-atps=neutral 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 3ydgps0x8Vz9ryr for ; Sat, 18 Nov 2017 01:43:48 +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=dkSszLjrA9vA p0l6lOPu55zPANz+htCBPrpecDL1Ac26UKv/cRFwIQrqM2cmbU5Wg/lrlZ+W/nbs 5UoMM6zRdNJOZjKNDZwY+f/kmLp26/hOpVY4hkWTTV3jytqDSJoG1sKj7aIptW/8 fBEaiRvQk4s5JD6yd1vk9H5eP+R5oPI= 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=GdCdkMjasr8o2O65VQ rexK5nlXY=; b=TXCgbyNmD9uXdfrHRcLUHqNZH/1zpBRklPcckQbtOq7etNaR3p v1i5KzvdKP7k0IofbTHmD4tdpLGIFUvObnnrZ++U3g1U4slhCn/BV4d60X05ofmf skYKACfJpooJxfXyVfAuHffS5TfwljIu/I31huC5FidkRShaRTknDqBuw= Received: (qmail 39764 invoked by alias); 17 Nov 2017 14:43:33 -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 39754 invoked by uid 89); 17 Nov 2017 14:43:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.0 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_LAZY_DOMAIN_SECURITY, KB_WAM_FROM_NAME_SINGLEWORD, RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= 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 ESMTP; Fri, 17 Nov 2017 14:43:31 +0000 Received: by gcc1-power7.osuosl.org (Postfix, from userid 10019) id 3A8EF12402A1; Fri, 17 Nov 2017 14:43:30 +0000 (UTC) From: Segher Boessenkool To: gcc-patches@gcc.gnu.org Cc: Segher Boessenkool Subject: [PATCH] combine: Don't split insns if half is unused (PR82621) Date: Fri, 17 Nov 2017 14:43:17 +0000 Message-Id: <51d4f4f94d6c64ab8ffb9e29d684adefb4ce22b0.1510921447.git.segher@kernel.crashing.org> X-IsSubscribed: yes If we have a PARALLEL of two SETs, and one half is unused, we currently happily split that into two instructions (albeit the unused one is useless). Worse, as PR82621 shows, combine will happily merge this insn into I3 even if some intervening insn sets the same register again, which is wrong. This fixes it by not splitting PARALLELs with REG_UNUSED notes. It all is handled fine by combine in that case; just the "single set that is unused" case isn't handled properly. This also results in better code: combine will now actually throw away the unused SET. (It still won't do that in an I3). Tested on powerpc64-linux {-m32,-m64}, committing to trunk, and I'll do backports next week. Segher 2017-11-17 Segher Boessenkool PR rtl-optimization/82621 * combine.c (try_combine): Do not split PARALLELs of two SETs if the dest of one of those SETs is unused. --- gcc/combine.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/combine.c b/gcc/combine.c index 910d4b0..99df84e 100644 --- a/gcc/combine.c +++ b/gcc/combine.c @@ -3036,7 +3036,8 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx_insn *i1, rtx_insn *i0, && is_parallel_of_n_reg_sets (PATTERN (i2), 2) && can_split_parallel_of_n_reg_sets (i2, 2) && !reg_used_between_p (SET_DEST (XVECEXP (PATTERN (i2), 0, 0)), i2, i3) - && !reg_used_between_p (SET_DEST (XVECEXP (PATTERN (i2), 0, 1)), i2, i3)) + && !reg_used_between_p (SET_DEST (XVECEXP (PATTERN (i2), 0, 1)), i2, i3) + && !find_reg_note (i2, REG_UNUSED, 0)) { /* If there is no I1, there is no I0 either. */ i0 = i1;