From patchwork Mon Oct 23 17:18:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116785 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4884052qgn; Mon, 23 Oct 2017 10:18:47 -0700 (PDT) X-Received: by 10.99.43.71 with SMTP id r68mr12586700pgr.348.1508779127297; Mon, 23 Oct 2017 10:18:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508779127; cv=none; d=google.com; s=arc-20160816; b=ifHGlcr+ju7XKtZII8ZvH8cZGCI/EmZ/n7bpd8j344gh6USbvhSjZhWqkX9Z2Atjbm YskmHIsKJKgTBGh0LicRSiPnGRkFet4jZTi8VIY73Dp+TYDYiBpH4cHKhvan3WU6+OaT keueqiMKxqNjZRaM5HRMzn8FswJeG8Pf0bL8VaW+C6AF7LTXgdBekXHxyX0sJ3JgLDyv c82HOsx03HxPFzfBtYdbtobGcFrzpSPWth6NwmiKSNgBRnMcDX3l11vDzMR9pH0WXT+b W+HoUCgQYhdCKOaKftBHoo9O1p3yhX4/9CyhoafG/cIo296Q/wowl7nCtr9kbZEdSqhV 2kZA== 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=qh2tYKfqxQstjfLy3PD8OMFGb0sSkjJyXGDeOcJDK14=; b=Ov7LvFk97QmZnvuxyBv+Fhk27cdgX3y35JUATNM0Bch3jaU6eJTRMwtSuhuOwgQplc E3PyZbzsqMD3QV11oEbMd5wnifVOhL2UM7+DIqGMRh0JLI4jGNgHvVw5b18z42+NlzWi sH4qmptCXeeFVZjGtvSzXw5jx43f8xVtLjbVbYNPtL44XIiQpMlDVjDfptcCbg5vlog0 NFdayWzIuI2jeKlvEEcMhO1fUmpBnAsBgfdbNgBnItDogLJFCvYNTegy6X0VBBNefcgN /OSIOat0hHXtmFVw6adX37DIVX92qfM+0ZmVqFJIWYXV+nR93CVUQDH0rguAE06J9cCJ aRxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ot4VBwR4; spf=pass (google.com: domain of gcc-patches-return-464817-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464817-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 i12si5179991pgn.621.2017.10.23.10.18.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:18:47 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464817-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=ot4VBwR4; spf=pass (google.com: domain of gcc-patches-return-464817-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464817-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=N7li8AUoRzlvBYTkq7o+mKkf9Kerz QuUXRyJl/JSH7iLs40J9D8e1F8NI6lIzY67gSICSbPByOhRBMlhIq5tmQIXgmYXe 9pRFC5BONiua+edajcymzsz4OEf29BGhDkxX5PXOvoNiuN/mcQyVNHfMxn5OGAhZ ahwPH+mz+gYues= 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=bcRqvIdJLhyeu891xG6hna+8ku8=; b=ot4 VBwR4zbXr5CctQVG+Jl2JohsEr8G/gR4FW0FnmXgPz122V0Y5Xdppnvl7kJe6bdX piLLNynOO4xOaihm43BUPMHq35IxaTlAwloPUl3j2fab6t9T9oLU0vHpk+vD583F OIIYh3/M1JyghsdAVkgviTpkbslZ6R+umvVmU2zo= Received: (qmail 65297 invoked by alias); 23 Oct 2017 17:18:07 -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 65130 invoked by uid 89); 23 Oct 2017 17:18:06 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.0 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=041 X-HELO: mail-wm0-f44.google.com Received: from mail-wm0-f44.google.com (HELO mail-wm0-f44.google.com) (74.125.82.44) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:18:04 +0000 Received: by mail-wm0-f44.google.com with SMTP id q124so10952546wmb.0 for ; Mon, 23 Oct 2017 10:18:04 -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=qh2tYKfqxQstjfLy3PD8OMFGb0sSkjJyXGDeOcJDK14=; b=SCc0T3AV7WRY9S/r9Pw/zySG8gZBarOq4YV2Z846qZfLbeebh3PolPuhCY+s9Xj/04 Doi85PTWgVJ1zjiU330CJKb0eWuk5jPQkkOiqmNKu3ebNLDRyGjAS6ZxrJDxqbkPdeH3 X5MGTPFmeA+W69/3HYWCYuzE3tFjN9TUBB9S1BBv/pmlbNloeGmhK7r1tjo8SKt05b14 FHcG0gTLtTT53bxNy987TSfNjcCgrYQ4MuWC4W5hZ2NDFjYtdXxQSKFy3mOIIk7Nklj6 o1L4Dr/gqR+K6gAQrKbf8VWvIQhNJKo+5fD47NDiF7nl3ryUBTz3kH88Up+PsAVJEjEp ieNw== X-Gm-Message-State: AMCzsaXgmHkXgC4zoleFheLP6JzrCJY7eagvWr61HoqmFdv16qIFzNek m2v6pV0DzLCZAg7gbuAZqzL5bJQpFL0= X-Google-Smtp-Source: ABhQp+S0A1iuwqf4sIGIl4KHwtCeW47wBbByAjhz0hedMi6Q1Fa4i0Fa+c7LX79occdujLK4DOIE6w== X-Received: by 10.28.19.73 with SMTP id 70mr6009729wmt.87.1508779081977; Mon, 23 Oct 2017 10:18:01 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id t18sm306353wrg.49.2017.10.23.10.18.00 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:18:01 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [041/nnn] poly_int: reload.c References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:18:00 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87y3o1n5pz.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes a few small poly_int64 changes to reload.c, such as in the "decomposition" structure. In practice, any port with polynomial-sized modes should be using LRA rather than reload, but it's easier to convert reload anyway than to sprinkle to_constants everywhere. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * reload.h (reload::inc): Change from an int to a poly_int64_pod. * reload.c (combine_reloads, debug_reload_to_stream): Likewise. (decomposition): Change start and end from HOST_WIDE_INT to poly_int64_pod. (decompose, immune_p): Update accordingly. (find_inc_amount): Return a poly_int64 rather than an int. * reload1.c (inc_for_reload): Take the inc_amount as a poly_int64 rather than an int. Index: gcc/reload.h =================================================================== --- gcc/reload.h 2017-10-23 17:07:40.266433752 +0100 +++ gcc/reload.h 2017-10-23 17:18:51.485721234 +0100 @@ -97,7 +97,7 @@ struct reload /* Positive amount to increment or decrement by if reload_in is a PRE_DEC, PRE_INC, POST_DEC, POST_INC. Ignored otherwise (don't assume it is zero). */ - int inc; + poly_int64_pod inc; /* A reg for which reload_in is the equivalent. If reload_in is a symbol_ref which came from reg_equiv_constant, then this is the pseudo Index: gcc/reload.c =================================================================== --- gcc/reload.c 2017-10-23 17:16:50.373527872 +0100 +++ gcc/reload.c 2017-10-23 17:18:51.485721234 +0100 @@ -168,8 +168,8 @@ struct decomposition int reg_flag; /* Nonzero if referencing a register. */ int safe; /* Nonzero if this can't conflict with anything. */ rtx base; /* Base address for MEM. */ - HOST_WIDE_INT start; /* Starting offset or register number. */ - HOST_WIDE_INT end; /* Ending offset or register number. */ + poly_int64_pod start; /* Starting offset or register number. */ + poly_int64_pod end; /* Ending offset or register number. */ }; /* Save MEMs needed to copy from one class of registers to another. One MEM @@ -278,7 +278,7 @@ static void find_reloads_address_part (r static rtx find_reloads_subreg_address (rtx, int, enum reload_type, int, rtx_insn *, int *); static void copy_replacements_1 (rtx *, rtx *, int); -static int find_inc_amount (rtx, rtx); +static poly_int64 find_inc_amount (rtx, rtx); static int refers_to_mem_for_reload_p (rtx); static int refers_to_regno_for_reload_p (unsigned int, unsigned int, rtx, rtx *); @@ -1772,7 +1772,7 @@ combine_reloads (void) && (ira_reg_class_max_nregs [(int)rld[i].rclass][(int) rld[i].inmode] == ira_reg_class_max_nregs [(int) rld[output_reload].rclass] [(int) rld[output_reload].outmode]) - && rld[i].inc == 0 + && known_zero (rld[i].inc) && rld[i].reg_rtx == 0 /* Don't combine two reloads with different secondary memory locations. */ @@ -2360,7 +2360,7 @@ operands_match_p (rtx x, rtx y) decompose (rtx x) { struct decomposition val; - int all_const = 0; + int all_const = 0, regno; memset (&val, 0, sizeof (val)); @@ -2458,29 +2458,33 @@ decompose (rtx x) case REG: val.reg_flag = 1; - val.start = true_regnum (x); - if (val.start < 0 || val.start >= FIRST_PSEUDO_REGISTER) + regno = true_regnum (x); + if (regno < 0 || regno >= FIRST_PSEUDO_REGISTER) { /* A pseudo with no hard reg. */ val.start = REGNO (x); val.end = val.start + 1; } else - /* A hard reg. */ - val.end = end_hard_regno (GET_MODE (x), val.start); + { + /* A hard reg. */ + val.start = regno; + val.end = end_hard_regno (GET_MODE (x), regno); + } break; case SUBREG: if (!REG_P (SUBREG_REG (x))) /* This could be more precise, but it's good enough. */ return decompose (SUBREG_REG (x)); - val.reg_flag = 1; - val.start = true_regnum (x); - if (val.start < 0 || val.start >= FIRST_PSEUDO_REGISTER) + regno = true_regnum (x); + if (regno < 0 || regno >= FIRST_PSEUDO_REGISTER) return decompose (SUBREG_REG (x)); - else - /* A hard reg. */ - val.end = val.start + subreg_nregs (x); + + /* A hard reg. */ + val.reg_flag = 1; + val.start = regno; + val.end = regno + subreg_nregs (x); break; case SCRATCH: @@ -2505,7 +2509,11 @@ immune_p (rtx x, rtx y, struct decomposi struct decomposition xdata; if (ydata.reg_flag) - return !refers_to_regno_for_reload_p (ydata.start, ydata.end, x, (rtx*) 0); + /* In this case the decomposition structure contains register + numbers rather than byte offsets. */ + return !refers_to_regno_for_reload_p (ydata.start.to_constant (), + ydata.end.to_constant (), + x, (rtx *) 0); if (ydata.safe) return 1; @@ -2536,7 +2544,7 @@ immune_p (rtx x, rtx y, struct decomposi return 0; } - return (xdata.start >= ydata.end || ydata.start >= xdata.end); + return must_ge (xdata.start, ydata.end) || must_ge (ydata.start, xdata.end); } /* Similar, but calls decompose. */ @@ -7063,7 +7071,7 @@ find_equiv_reg (rtx goal, rtx_insn *insn within X, and return the amount INCED is incremented or decremented by. The value is always positive. */ -static int +static poly_int64 find_inc_amount (rtx x, rtx inced) { enum rtx_code code = GET_CODE (x); @@ -7096,8 +7104,8 @@ find_inc_amount (rtx x, rtx inced) { if (fmt[i] == 'e') { - int tem = find_inc_amount (XEXP (x, i), inced); - if (tem != 0) + poly_int64 tem = find_inc_amount (XEXP (x, i), inced); + if (maybe_nonzero (tem)) return tem; } if (fmt[i] == 'E') @@ -7105,8 +7113,8 @@ find_inc_amount (rtx x, rtx inced) int j; for (j = XVECLEN (x, i) - 1; j >= 0; j--) { - int tem = find_inc_amount (XVECEXP (x, i, j), inced); - if (tem != 0) + poly_int64 tem = find_inc_amount (XVECEXP (x, i, j), inced); + if (maybe_nonzero (tem)) return tem; } } @@ -7267,8 +7275,11 @@ debug_reload_to_stream (FILE *f) if (rld[r].nongroup) fprintf (f, ", nongroup"); - if (rld[r].inc != 0) - fprintf (f, ", inc by %d", rld[r].inc); + if (maybe_nonzero (rld[r].inc)) + { + fprintf (f, ", inc by "); + print_dec (rld[r].inc, f, SIGNED); + } if (rld[r].nocombine) fprintf (f, ", can't combine"); Index: gcc/reload1.c =================================================================== --- gcc/reload1.c 2017-10-23 17:16:50.373527872 +0100 +++ gcc/reload1.c 2017-10-23 17:18:51.486721146 +0100 @@ -398,7 +398,7 @@ static void emit_reload_insns (struct in static void delete_output_reload (rtx_insn *, int, int, rtx); static void delete_address_reloads (rtx_insn *, rtx_insn *); static void delete_address_reloads_1 (rtx_insn *, rtx, rtx_insn *); -static void inc_for_reload (rtx, rtx, rtx, int); +static void inc_for_reload (rtx, rtx, rtx, poly_int64); static void add_auto_inc_notes (rtx_insn *, rtx); static void substitute (rtx *, const_rtx, rtx); static bool gen_reload_chain_without_interm_reg_p (int, int); @@ -9075,7 +9075,7 @@ delete_address_reloads_1 (rtx_insn *dead This cannot be deduced from VALUE. */ static void -inc_for_reload (rtx reloadreg, rtx in, rtx value, int inc_amount) +inc_for_reload (rtx reloadreg, rtx in, rtx value, poly_int64 inc_amount) { /* REG or MEM to be copied and incremented. */ rtx incloc = find_replacement (&XEXP (value, 0)); @@ -9105,7 +9105,7 @@ inc_for_reload (rtx reloadreg, rtx in, r if (GET_CODE (value) == PRE_DEC || GET_CODE (value) == POST_DEC) inc_amount = -inc_amount; - inc = GEN_INT (inc_amount); + inc = gen_int_mode (inc_amount, Pmode); } /* If this is post-increment, first copy the location to the reload reg. */