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: 787609 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 3x7VCj4czGz9ryv for ; Thu, 13 Jul 2017 19:00:49 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="socsxllw"; 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:subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=default; b=ZhhEfY095qMNZkyPcP13+1NoLZbgU tDyT2h0CZaDOTCbD5bBu+u6RzgMQoNqkSg2ha3pp8ivF5BK6WYBpDvdMYn2wdkfb L6FGEC6+uh8eI6Hvt65vUmgLZSLkp8deiXBJwS5wg/TWNz/CooI/B5ipTAQQFKsf XBQZKlvhrGH5UQ= 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=soc sxllwAAq3DkPbH+xl6Cf4jQ2iKPwxkx7Pe41E7a2iFNYnwQjgxb7sNb6jizNckjO tDgJ2VFLzJXJ9+RNjETWD4yfecA/NawABP84hSAXUGy6f3xYifrFXcpKYde8lFp6 AELcHzOSdM9dZMcePrMyqeISEkmUlVfuFElkkxS0= 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);