From patchwork Wed Aug 23 10:51:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 110731 Delivered-To: patch@linaro.org Received: by 10.140.95.78 with SMTP id h72csp3941270qge; Wed, 23 Aug 2017 03:51:50 -0700 (PDT) X-Received: by 10.99.172.17 with SMTP id v17mr2278413pge.196.1503485510430; Wed, 23 Aug 2017 03:51:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1503485510; cv=none; d=google.com; s=arc-20160816; b=QJKYyI3GW5mNucOAZRbJXtma7lx5bnKhwk6qM2z4j5Da1vD9w3ZFXqvx42WP9k1P2F sivLmU+3gOsMpzRo1NMkvd0oDM5lq2EUdEBbct1CZivXrttMI2HzWsPciQmmynDy+lDI 55wremSivx8e26wUPe87JzW0czHSF12A/TeMWax0b4HQkbGMqMEsMP76DDGy47H3V4Kv 9CGzdz6oFKLwUhPp3Kf9OE05nkdYz20uymzKkrSayIHdE2uZxE9NVYlhf4VqbCefwq5k BvbJjV0BKUVIOZFP9sTv34BeLOtLmCmGNM3apMkIl/El7qG+oLj7wFF1C028apEHUlJ2 BtmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:user-agent:message-id:date: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=9W6XmVRsOWW7NABLWgWTvaWBUGJvGgN9fi50f/0udAU=; b=NC4Qkj8LU8MEopOfSjBTez78itE60EAEGXWyxPkPuJvhcEcPJUjBpnHX0PwoPGMekP m5KLVvOPRjPG0hd4O/0tVKLiMHMyeUZF5XAP3dJYjYqCStM7v7BtV3j81s6VBdMOEL8j stNxWgp14ueNfMk3xTUDffYTO05p/d0E0A8CIs9eKl2jGyEWnlQkIMn92FjEuYyJH0eD 2g8QdiiEqfuwiq2PQIgPgUib5mh6et0sHES1IZq/1M1yi1h/m3A+aSTHgdLFdnIgVBEc JZDDGZw247fHxxCF1aI7xxCcox9xQ0LR0g9gEOrs6LMOvqb1GBC/DBaYhNUxE9IUyi5q Oi6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=A0EgOrQR; spf=pass (google.com: domain of gcc-patches-return-460784-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460784-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 s2si853807pfk.431.2017.08.23.03.51.49 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Aug 2017 03:51:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-460784-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.s=default header.b=A0EgOrQR; spf=pass (google.com: domain of gcc-patches-return-460784-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-460784-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:date:message-id:mime-version:content-type; q=dns; s= default; b=qqCZsqBT1ltaJmL132Tv54tmg44cY1r9LymZrol0pQztR+cn/EL7z g/nYkwzh2BXsZm9sbICTtwb8ItpfEZQZGfBNZB+6DZnxX97R9awjAGZxgLMvo5dy YuhUyPy6DfGCe3sL3uEmNQjGLg8nSHSiHX/vpT13kaztGfhPXBp1rc= 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:date:message-id:mime-version:content-type; s= default; bh=g09oR1ESBCKejkHJ21b6KnZyTX8=; b=A0EgOrQR2Q5geBvbcCSw vbGzHyRkR65j1Atl0SWRM0IE1f+1BwsTiAmlPSPp7SR6nUBNogbrelSmnlovq8uC fXSBn+0P4tvCjLzsBu3UT1YQtxT5IRb8DWuvqjNihZN0V6dASLABBIM4TpyPfa8N sM/3mGil1hFsfuB6TU1osB0= Received: (qmail 3262 invoked by alias); 23 Aug 2017 10:51:36 -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 3246 invoked by uid 89); 23 Aug 2017 10:51:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-10.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wr0-f175.google.com Received: from mail-wr0-f175.google.com (HELO mail-wr0-f175.google.com) (209.85.128.175) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 23 Aug 2017 10:51:34 +0000 Received: by mail-wr0-f175.google.com with SMTP id p8so4304507wrf.5 for ; Wed, 23 Aug 2017 03:51:33 -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:date:message-id :user-agent:mime-version; bh=9W6XmVRsOWW7NABLWgWTvaWBUGJvGgN9fi50f/0udAU=; b=L2pr7yj5eOjkEmXicNFo5iUQ6invVLnKLgeuLYd6CgmdFaUUwDDvZ/9pBumNrGFcDC 8SkX0Ouq/BsdSpihbVTS4ukhAJxKaiZSd9E9uf93aZm5BWjcGjmGh4djCXse17JHAZt8 mzD03Svn6j38vggcv1upOZhpMpiuU7OAIy0QFiBJjiIk3vWs/Y1NSlELLfxbr4rgb/aT NCEnfuZ15/dr24ES64yfYpl6ZIEeLMTrYQbRg83TTLdSLUX/4RceopXybabDol8PHRHm qHkQCvnrUHAQEj7C0PKn513bPyIC0jPewwjvJVGuFUcDcIBqewtpJ3pDAHnaBbq9Cyvm MgBg== X-Gm-Message-State: AHYfb5ico5VAhQAFsGUeuSFedwvmsBTsclfk3SyCqzyXt8VWspMsLNcj MvBX+EuO+Avg+46srQubTw== X-Received: by 10.223.187.66 with SMTP id x2mr1477940wrg.310.1503485491860; Wed, 23 Aug 2017 03:51:31 -0700 (PDT) Received: from localhost (92.40.249.210.threembb.co.uk. [92.40.249.210]) by smtp.gmail.com with ESMTPSA id 36sm1026032wrh.77.2017.08.23.03.51.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Aug 2017 03:51:31 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Make more use of subreg_lowpart_offset Date: Wed, 23 Aug 2017 11:51:28 +0100 Message-ID: <871so2v9ov.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch uses subreg_lowpart_offset in places that open-coded the calculation. It also uses it in regcprop.c to test whether, after a mode change, the first register in a multi-register group is still the right one. Tested on aarch64-linux-gnu and x86_64-linux-gnu, and by making sure that there were no differences in testsuite assembly output for one target per CPU. OK to install? Richard 2017-08-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * calls.c (expand_call): Use subreg_lowpart_offset. * cse.c (cse_insn): Likewise. * regcprop.c (copy_value): Likewise. (copyprop_hardreg_forward_1): Likewise. Index: gcc/calls.c =================================================================== --- gcc/calls.c 2017-08-21 15:49:31.653164829 +0100 +++ gcc/calls.c 2017-08-23 10:46:06.552151584 +0100 @@ -4128,7 +4128,6 @@ expand_call (tree exp, rtx target, int i { tree type = rettype; int unsignedp = TYPE_UNSIGNED (type); - int offset = 0; machine_mode pmode; /* Ensure we promote as expected, and get the new unsignedness. */ @@ -4136,18 +4135,8 @@ expand_call (tree exp, rtx target, int i funtype, 1); gcc_assert (GET_MODE (target) == pmode); - if ((WORDS_BIG_ENDIAN || BYTES_BIG_ENDIAN) - && (GET_MODE_SIZE (GET_MODE (target)) - > GET_MODE_SIZE (TYPE_MODE (type)))) - { - offset = GET_MODE_SIZE (GET_MODE (target)) - - GET_MODE_SIZE (TYPE_MODE (type)); - if (! BYTES_BIG_ENDIAN) - offset = (offset / UNITS_PER_WORD) * UNITS_PER_WORD; - else if (! WORDS_BIG_ENDIAN) - offset %= UNITS_PER_WORD; - } - + unsigned int offset = subreg_lowpart_offset (TYPE_MODE (type), + GET_MODE (target)); target = gen_rtx_SUBREG (TYPE_MODE (type), target, offset); SUBREG_PROMOTED_VAR_P (target) = 1; SUBREG_PROMOTED_SET (target, unsignedp); Index: gcc/cse.c =================================================================== --- gcc/cse.c 2017-08-22 17:14:30.334912144 +0100 +++ gcc/cse.c 2017-08-23 10:46:06.552151584 +0100 @@ -5964,7 +5964,6 @@ cse_insn (rtx_insn *insn) rtx new_src = 0; unsigned src_hash; struct table_elt *src_elt; - int byte = 0; /* Ignore invalid entries. */ if (!REG_P (elt->exp) @@ -5977,13 +5976,8 @@ cse_insn (rtx_insn *insn) new_src = elt->exp; else { - /* Calculate big endian correction for the SUBREG_BYTE. - We have already checked that M1 (GET_MODE (dest)) - is not narrower than M2 (new_mode). */ - if (BYTES_BIG_ENDIAN) - byte = (GET_MODE_SIZE (GET_MODE (dest)) - - GET_MODE_SIZE (new_mode)); - + unsigned int byte + = subreg_lowpart_offset (new_mode, GET_MODE (dest)); new_src = simplify_gen_subreg (new_mode, elt->exp, GET_MODE (dest), byte); } Index: gcc/regcprop.c =================================================================== --- gcc/regcprop.c 2017-08-21 15:49:31.652164829 +0100 +++ gcc/regcprop.c 2017-08-23 10:46:06.553156355 +0100 @@ -344,8 +344,7 @@ copy_value (rtx dest, rtx src, struct va We can't properly represent the latter case in our tables, so don't record anything then. */ else if (sn < (unsigned int) hard_regno_nregs[sr][vd->e[sr].mode] - && (GET_MODE_SIZE (vd->e[sr].mode) > UNITS_PER_WORD - ? WORDS_BIG_ENDIAN : BYTES_BIG_ENDIAN)) + && subreg_lowpart_offset (GET_MODE (dest), vd->e[sr].mode) != 0) return; /* If SRC had been assigned a mode narrower than the copy, we can't @@ -878,8 +877,7 @@ copyprop_hardreg_forward_1 (basic_block is also invalid. */ if (hard_regno_nregs[regno][mode] < hard_regno_nregs[regno][vd->e[regno].mode] - && (GET_MODE_SIZE (vd->e[regno].mode) > UNITS_PER_WORD - ? WORDS_BIG_ENDIAN : BYTES_BIG_ENDIAN)) + && subreg_lowpart_offset (mode, vd->e[regno].mode) != 0) goto no_move_special_case; }