From patchwork Thu Jul 13 08:59:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 107644 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1940846qge; Thu, 13 Jul 2017 02:00:56 -0700 (PDT) X-Received: by 10.99.134.199 with SMTP id x190mr8219775pgd.127.1499936456384; Thu, 13 Jul 2017 02:00:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499936456; cv=none; d=google.com; s=arc-20160816; b=vm7t+l/xJKlsMv8npIBEKEnexr60sf4JBDeHCOvhpu9n44v1OUiHMHOA+31M3mVjvP tKi8tzzL0yCx7mb8jydkkaTh4Bu0UiDapAYzUKU0duAK9XhN0Mr0uXx1JWwNH2sf1ypu TFTc9PcdaTZq7M2nNHb/dq6P8yPccEBiWXOat38H7/ZYslREFHXPFea3RYJMpFJ3N7U+ 62LAGxoL/NtWB18MeSd7l+NnUCx7IGoBPcWfEUrMdHIY25GONQBRAQjOoU8+CsGLuGWs l1yKPG1AjgyIQ0V7mOCM1cSJdZ5gqbh8ry6Azo1TFohizX77XlJxBc3v/rJIbx+zIjE7 q0gA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:in-reply-to:date:references :subject:mail-followup-to:to:from:delivered-to:sender:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mailing-list:dkim-signature:domainkey-signature :arc-authentication-results; bh=zH84uyU3CqRp/sTSshfWm50/r7ayVhhZx5hz78fOQaA=; b=ayv6hFqlcxCkGxyCFWgUhQCBj4rsRDw5uedT23//plWrrbQhwwN9OeSc6JGhKCwVTN vLKs5tyks144pph2qpZ8GxtUaWu8SWn8AOMLh39zSAYhT1y1gpfp0FgyJ9s3y1oFiLFy 8qtYA1I2iYxcLFIOi+CfLbVHa1w29KvrTHoBUgtJ32QDN1jRQ960IpVWS4MBofI9Qa6C YMlD36d0MgQlp/DwOg4rZtdjeHL9u5ijcmAhbcLw59sJ2GameBkoXn+5Nsh99i7QuZ/p Hh65Tgw0D5o24VI3nyl7j/aO6tYasp9u2NDe5sdqF3+T/uMHSPTixy5N+Q35zayBqtdf Ajkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=KUGm9kJO; spf=pass (google.com: domain of gcc-patches-return-458049-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458049-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id y5si3861724pgq.414.2017.07.13.02.00.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 02:00:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-458049-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.b=KUGm9kJO; spf=pass (google.com: domain of gcc-patches-return-458049-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-458049-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=ep+K21t85EEFxfzC+12J2w0o/Gc35 YaveQ/dBR9+oKGlw5PM+st1BUvAxgNzWr9iyLFTGTzzi5ALGTqNi3yYHpDkteNfA 4IkFxlTnhOz9DGWSJ9HjAE8J0S/MsaozcEvPMNyTfJqBVDXwdFCffKYl1VZQx+k0 4qcYo0xGkrDkhE= 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:subject:references:date:in-reply-to:message-id:mime-version :content-type; s=default; bh=2iYMbjW44fTdXk4wPBsPgbwIYMY=; b=KUG m9kJOKk6tFRAoh5SyossjoKienD/x3FEzoLojqiVyKPj3JtA4mjRhuQWns6doIZh Er87gQ4C/vq/3xMxFkhrtcgu37Jz9wPZGEqSFdToraSnggGeeeKrs9rNCy7PPqa5 WNlsE80X3RWvxQA6zFV3Q9JKRaZoZgwhF7XxnTYo= Received: (qmail 43589 invoked by alias); 13 Jul 2017 08:59:22 -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 42781 invoked by uid 89); 13 Jul 2017 08:59:21 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.4 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:3738 X-HELO: mail-wr0-f173.google.com Received: from mail-wr0-f173.google.com (HELO mail-wr0-f173.google.com) (209.85.128.173) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 13 Jul 2017 08:59:15 +0000 Received: by mail-wr0-f173.google.com with SMTP id k67so49481058wrc.2 for ; Thu, 13 Jul 2017 01:59:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:mail-followup-to:subject:references:date :in-reply-to:message-id:user-agent:mime-version; bh=zH84uyU3CqRp/sTSshfWm50/r7ayVhhZx5hz78fOQaA=; b=XxqtT3xmP9wwpIQWr4oZv5Vo4w/2H1C8fwDyTXkkWKhJo1lCnqwJMiNx0+fYCAx+Py /YtrskV3b7bTTxIr+u20Xp4D2xoAdEM+p4mG6vNZij56kh5y0Fg6qt9JopiOJ8JK7/+d F/PY6vw5KkbV63e5meLXxXiExDaSRiGBahI1H2frwapzT4hcp4Pgi7I2JCdKDOXeIJpM AuhQHFpVZZ7u/8asPvdFRlpdGHn/WNr32lJsjNoz8Bx2l52NZIF5BCpZ+WdSzx3Tx3Yv 1NsWfUU0raHD9Rh17Vzw9lWyIq+8z80sp+M8hJNGW2FlJnKGCMIIOB2oRBq8oOpZ0ZTo t1Iw== X-Gm-Message-State: AIVw112FTBJ0B4UES48Wm9nNV+FxLTYmfVMA5ax8JrLQhfDigwVAB1X4 m10/I6Yfr6c+AIPW4VQuvQ== X-Received: by 10.223.128.177 with SMTP id 46mr893134wrl.150.1499936353106; Thu, 13 Jul 2017 01:59:13 -0700 (PDT) Received: from localhost (92.40.249.184.threembb.co.uk. [92.40.249.184]) by smtp.gmail.com with ESMTPSA id r191sm6110650wmg.6.2017.07.13.01.59.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Jul 2017 01:59:12 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [58/77] Use scalar_int_mode in a try_combine optimisation References: <8760ewohsv.fsf@linaro.org> Date: Thu, 13 Jul 2017 09:59:10 +0100 In-Reply-To: <8760ewohsv.fsf@linaro.org> (Richard Sandiford's message of "Thu, 13 Jul 2017 09:35:44 +0100") Message-ID: <877ezcemqp.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch uses scalar_int_modes for: /* If I2 is setting a pseudo to a constant and I3 is setting some sub-part of it to another constant, merge them by making a new constant. */ This was already implicit, but the danger with checking only CONST_SCALAR_INT_P is that it can include CC values too. 2017-07-13 Richard Sandiford Alan Hayward David Sherwood gcc/ * combine.c (try_combine): Use is_a when trying to combine a full-register integer set with a subreg integer set. Index: gcc/combine.c =================================================================== --- gcc/combine.c 2017-07-13 09:18:45.761227536 +0100 +++ gcc/combine.c 2017-07-13 09:18:49.526933168 +0100 @@ -2645,6 +2645,7 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx other_pat = 0; rtx new_other_notes; int i; + scalar_int_mode dest_mode, temp_mode; /* Immediately return if any of I0,I1,I2 are the same insn (I3 can never be). */ @@ -2847,33 +2848,40 @@ try_combine (rtx_insn *i3, rtx_insn *i2, constant. */ if (i1 == 0 && (temp_expr = single_set (i2)) != 0 + && is_a (GET_MODE (SET_DEST (temp_expr)), &temp_mode) && CONST_SCALAR_INT_P (SET_SRC (temp_expr)) && GET_CODE (PATTERN (i3)) == SET && CONST_SCALAR_INT_P (SET_SRC (PATTERN (i3))) && reg_subword_p (SET_DEST (PATTERN (i3)), SET_DEST (temp_expr))) { rtx dest = SET_DEST (PATTERN (i3)); + rtx temp_dest = SET_DEST (temp_expr); int offset = -1; int width = 0; - + if (GET_CODE (dest) == ZERO_EXTRACT) { if (CONST_INT_P (XEXP (dest, 1)) - && CONST_INT_P (XEXP (dest, 2))) + && CONST_INT_P (XEXP (dest, 2)) + && is_a (GET_MODE (XEXP (dest, 0)), + &dest_mode)) { width = INTVAL (XEXP (dest, 1)); offset = INTVAL (XEXP (dest, 2)); dest = XEXP (dest, 0); if (BITS_BIG_ENDIAN) - offset = GET_MODE_PRECISION (GET_MODE (dest)) - width - offset; + offset = GET_MODE_PRECISION (dest_mode) - width - offset; } } else { if (GET_CODE (dest) == STRICT_LOW_PART) dest = XEXP (dest, 0); - width = GET_MODE_PRECISION (GET_MODE (dest)); - offset = 0; + if (is_a (GET_MODE (dest), &dest_mode)) + { + width = GET_MODE_PRECISION (dest_mode); + offset = 0; + } } if (offset >= 0) @@ -2882,9 +2890,9 @@ try_combine (rtx_insn *i3, rtx_insn *i2, if (subreg_lowpart_p (dest)) ; /* Handle the case where inner is twice the size of outer. */ - else if (GET_MODE_PRECISION (GET_MODE (SET_DEST (temp_expr))) - == 2 * GET_MODE_PRECISION (GET_MODE (dest))) - offset += GET_MODE_PRECISION (GET_MODE (dest)); + else if (GET_MODE_PRECISION (temp_mode) + == 2 * GET_MODE_PRECISION (dest_mode)) + offset += GET_MODE_PRECISION (dest_mode); /* Otherwise give up for now. */ else offset = -1; @@ -2895,23 +2903,22 @@ try_combine (rtx_insn *i3, rtx_insn *i2, rtx inner = SET_SRC (PATTERN (i3)); rtx outer = SET_SRC (temp_expr); - wide_int o - = wi::insert (rtx_mode_t (outer, GET_MODE (SET_DEST (temp_expr))), - rtx_mode_t (inner, GET_MODE (dest)), - offset, width); + wide_int o = wi::insert (rtx_mode_t (outer, temp_mode), + rtx_mode_t (inner, dest_mode), + offset, width); combine_merges++; subst_insn = i3; subst_low_luid = DF_INSN_LUID (i2); added_sets_2 = added_sets_1 = added_sets_0 = 0; - i2dest = SET_DEST (temp_expr); + i2dest = temp_dest; i2dest_killed = dead_or_set_p (i2, i2dest); /* Replace the source in I2 with the new constant and make the resulting insn the new pattern for I3. Then skip to where we validate the pattern. Everything was set up above. */ SUBST (SET_SRC (temp_expr), - immed_wide_int_const (o, GET_MODE (SET_DEST (temp_expr)))); + immed_wide_int_const (o, temp_mode)); newpat = PATTERN (i2);