From patchwork Mon Sep 11 17:15:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 112206 Delivered-To: patch@linaro.org Received: by 10.140.106.117 with SMTP id d108csp4099595qgf; Mon, 11 Sep 2017 10:15:45 -0700 (PDT) X-Received: by 10.84.253.147 with SMTP id a19mr14276570plm.14.1505150145852; Mon, 11 Sep 2017 10:15:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1505150145; cv=none; d=google.com; s=arc-20160816; b=mCxGr2FbvV0jYyucIoGrmTfsuLgmqqR9PXzfhct8nBq7AjseYkTSdIhUXZJAoEtCxD m/ubuiuQ8zq0UUnD845++JJdKXvKW5qLaa02bI3VE/MMlzVfnCOptfnjoF/2ElWyM3yn 0MFbv0Z2hJwMF93XhlvpCjljhPRLR0TWHNyWE4ZkbBt+ZcrXfmNVuzNFrZ2VWbz2S8Ff uIjFKxgL0H6GGqoiVvNjzOJToZeS1YxfIsWCYbeVOW2EEWtoTa3mLHhaIwhaHrdwaneJ EBtVbOqneKwD4u57stxuDDQ5IgfPwCEbkzCIbMmC732TYNGq7eAaV8ipMJbSx16RUyCq bn0Q== 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=J6U672KDztPvWBRLHwvWWp0OJN4AxXBIkj83Y17F5NI=; b=I+2gtxgrA7Nuuzsp/elfzTKSkUXe78CsAHILkoksm2hhjwoqs6b1KzMSYCuKRWKSEW UPlYXkusULOdYQOAeOoNzVz9naVP8rnUnih9RlDXGv03eN1QZXL6caFmNukPpIBsA3lD mdwy/FbIUhjJQLbMvV5MeQ3585t0RHUuP5SVWAoHguz4r0WZgIsRwprdBOy+FtgP00J8 4ZClo4UdAcpfLjiK/DfO3B2IEFq9KAL1ZTxtAOVcmPkF6Ls7bRo9h9dFVFacR0ZPnLAY PTWgxG0ZWaecjNYi43V5J6MqGXwcuSu+op5asPJkQam8EfhWDhdgN2Ya8lCAL/76JETA YTfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Vfp/LctV; spf=pass (google.com: domain of gcc-patches-return-461838-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-461838-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 o32si7039753pld.407.2017.09.11.10.15.45 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Sep 2017 10:15:45 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-461838-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=Vfp/LctV; spf=pass (google.com: domain of gcc-patches-return-461838-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-461838-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=Wb4m7pB/yv8kzmH+34wlg7+tJGqD9U/O8fytzR4tkE+wmmIhaMflL gciQ2nGQt9jaNv9UEFyuJzKHfEICHExVI1qXM/yxCdEPozZ74snoH8KeM9JXQUFZ CcPfNbqOlGOkv8mFAziTlB4nxtLPi4QWDxuGrbhnRM8Qhh26lhYkNU= 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=wcf8l/1iU1KRkTB8imbBI1KALMY=; b=Vfp/LctVux8RTLpMTBB3 N98dVZmQYyfvVWFLdRP8aDaRVb4iLG/S1hDhBuWEGyAQLKeN5OUKHSSzMhHTmdoz Qx3go5Ww3RbFVH1hznmgTDZC0oAUrOGYrJhgUSNjkdrPaOe95Fa7h3RFRW3SSgJI 0GPN4mwpuWB8rUVpaeAuAjM= Received: (qmail 5863 invoked by alias); 11 Sep 2017 17:15:34 -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 4892 invoked by uid 89); 11 Sep 2017 17:15:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 11 Sep 2017 17:15:31 +0000 Received: by mail-wm0-f42.google.com with SMTP id 189so10221534wmh.1 for ; Mon, 11 Sep 2017 10:15:31 -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=J6U672KDztPvWBRLHwvWWp0OJN4AxXBIkj83Y17F5NI=; b=bm/MdTeNdhx510deuyb8g8r4qSLxVQXwXnbae4Mf0pqFfmKQKoNnZOaGDt3aaHut8j pCiUckkJHAuZQG5XHX4Am4kKWwd1rWNjAqIhJJI9+v6GOCErNsNIelfHeiXHWVcELrmz QfCIBQRQ0ZNBXMo3Qlrh0gIBUtmiPI/3eolKnESxnBCONGGtoQL3fPTY9GPW1xmHI4K/ AohF90pCJtcTEqdO57zW5G1Bi/UT993sFAXV85HcRj+qCnZ5tgPHREhK3d7B5aRtMiWp Umj6m1nNbXzYhJaWk1oTHTb30ZlUjTacdp3G9ANMVuULebMKXk4F+Op+6f9SvO8OitkV nMsQ== X-Gm-Message-State: AHPjjUgono2hkbiAxtsaL/TjW1h/HdjVuarIhqnFWv8DXgrGiFONW3mE bKUsXS5p3FSw5686lFcjMw== X-Google-Smtp-Source: AOwi7QC2/LkmR/fTO2przEIVaEttI3KJo4sW6PdxnZMybf4ksEHuiU5qJ0v8STgIs1gIhsOzMkwuPg== X-Received: by 10.28.195.132 with SMTP id t126mr8025154wmf.0.1505150129253; Mon, 11 Sep 2017 10:15:29 -0700 (PDT) Received: from localhost ([2.25.234.0]) by smtp.gmail.com with ESMTPSA id l73sm18211546wma.24.2017.09.11.10.15.28 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 11 Sep 2017 10:15:28 -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 END_REGNO Date: Mon, 11 Sep 2017 18:15:27 +0100 Message-ID: <87vakpcg28.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 An upcoming patch will convert hard_regno_nregs into an inline function, which in turn allows hard_regno_nregs to be used as the name of a targetm field. This patch rewrites uses that are more easily (and efficiently) written as END_REGNO. Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu. Also tested by comparing the testsuite assembly output on at least one target per CPU directory. OK to install? Richard 2017-09-11 Richard Sandiford gcc/ * config/frv/frv.c (FOR_EACH_REGNO): Use END_REGNO instead of hard_regno_nregs. * config/v850/v850.c (v850_reorg): Likewise. * reload.c (refers_to_regno_for_reload_p): Likewise. (find_equiv_reg): Likewise. * reload1.c (reload_reg_reaches_end_p): Likewise. Index: gcc/config/frv/frv.c =================================================================== --- gcc/config/frv/frv.c 2017-09-04 11:50:08.510328712 +0100 +++ gcc/config/frv/frv.c 2017-09-11 17:17:46.893352269 +0100 @@ -135,9 +135,7 @@ #define CLEAR_PACKING_FLAG(INSN) PUT_MOD /* Loop with REG set to each hard register in rtx X. */ #define FOR_EACH_REGNO(REG, X) \ - for (REG = REGNO (X); \ - REG < REGNO (X) + HARD_REGNO_NREGS (REGNO (X), GET_MODE (X)); \ - REG++) + for (REG = REGNO (X); REG < END_REGNO (X); REG++) /* This structure contains machine specific function data. */ struct GTY(()) machine_function Index: gcc/config/v850/v850.c =================================================================== --- gcc/config/v850/v850.c 2017-09-04 11:50:08.540941953 +0100 +++ gcc/config/v850/v850.c 2017-09-11 17:17:46.893352269 +0100 @@ -1376,12 +1376,11 @@ v850_reorg (void) for the register */ if (GET_CODE (dest) == REG) { - machine_mode mode = GET_MODE (dest); int regno; int endregno; regno = REGNO (dest); - endregno = regno + HARD_REGNO_NREGS (regno, mode); + endregno = END_REGNO (dest); if (!use_ep) { Index: gcc/reload.c =================================================================== --- gcc/reload.c 2017-09-11 17:16:57.896550936 +0100 +++ gcc/reload.c 2017-09-11 17:17:46.894352229 +0100 @@ -6439,10 +6439,7 @@ refers_to_regno_for_reload_p (unsigned i return 0; } - return (endregno > r - && regno < r + (r < FIRST_PSEUDO_REGISTER - ? hard_regno_nregs[r][GET_MODE (x)] - : 1)); + return endregno > r && regno < END_REGNO (x); case SUBREG: /* If this is a SUBREG of a hard reg, we can see exactly which @@ -6889,15 +6886,11 @@ find_equiv_reg (rtx goal, rtx_insn *insn { int i; for (i = 0; i < n_reloads; i++) - if (rld[i].reg_rtx != 0 && rld[i].in) - { - int regno1 = REGNO (rld[i].reg_rtx); - int nregs1 = hard_regno_nregs[regno1] - [GET_MODE (rld[i].reg_rtx)]; - if (regno1 < valueno + valuenregs - && regno1 + nregs1 > valueno) - return 0; - } + if (rld[i].reg_rtx != 0 + && rld[i].in + && (int) REGNO (rld[i].reg_rtx) < valueno + valuenregs + && (int) END_REGNO (rld[i].reg_rtx) > valueno) + return 0; } if (goal_mem) @@ -6963,15 +6956,11 @@ find_equiv_reg (rtx goal, rtx_insn *insn if (REG_P (dest)) { int xregno = REGNO (dest); - int xnregs; - if (REGNO (dest) < FIRST_PSEUDO_REGISTER) - xnregs = hard_regno_nregs[xregno][GET_MODE (dest)]; - else - xnregs = 1; - if (xregno < regno + nregs && xregno + xnregs > regno) + int end_xregno = END_REGNO (dest); + if (xregno < regno + nregs && end_xregno > regno) return 0; if (xregno < valueno + valuenregs - && xregno + xnregs > valueno) + && end_xregno > valueno) return 0; if (goal_mem_addr_varies && reg_overlap_mentioned_for_reload_p (dest, goal)) @@ -7006,16 +6995,12 @@ find_equiv_reg (rtx goal, rtx_insn *insn if (REG_P (dest)) { int xregno = REGNO (dest); - int xnregs; - if (REGNO (dest) < FIRST_PSEUDO_REGISTER) - xnregs = hard_regno_nregs[xregno][GET_MODE (dest)]; - else - xnregs = 1; + int end_xregno = END_REGNO (dest); if (xregno < regno + nregs - && xregno + xnregs > regno) + && end_xregno > regno) return 0; if (xregno < valueno + valuenregs - && xregno + xnregs > valueno) + && end_xregno > valueno) return 0; if (goal_mem_addr_varies && reg_overlap_mentioned_for_reload_p (dest, @@ -7052,14 +7037,13 @@ find_equiv_reg (rtx goal, rtx_insn *insn if (REG_P (dest)) { int xregno = REGNO (dest); - int xnregs - = hard_regno_nregs[xregno][GET_MODE (dest)]; + int end_xregno = END_REGNO (dest); if (xregno < regno + nregs - && xregno + xnregs > regno) + && end_xregno > regno) return 0; else if (xregno < valueno + valuenregs - && xregno + xnregs > valueno) + && end_xregno > valueno) return 0; else if (goal_mem_addr_varies && reg_overlap_mentioned_for_reload_p (dest, Index: gcc/reload1.c =================================================================== --- gcc/reload1.c 2017-09-11 17:16:57.897550882 +0100 +++ gcc/reload1.c 2017-09-11 17:17:46.895352189 +0100 @@ -5350,15 +5350,13 @@ reload_reg_reaches_end_p (unsigned int r for (i = reloadnum + 1; i < n_reloads; i++) { rtx reg; - int nregs; if (rld[i].opnum != opnum || rld[i].when_needed != type) continue; reg = rld[i].reg_rtx; if (reg == NULL_RTX) continue; - nregs = hard_regno_nregs[REGNO (reg)][GET_MODE (reg)]; - if (regno >= REGNO (reg) && regno < REGNO (reg) + nregs) + if (regno >= REGNO (reg) && regno < END_REGNO (reg)) return 0; }