From patchwork Mon Oct 23 17:39:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116842 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4902836qgn; Mon, 23 Oct 2017 10:40:04 -0700 (PDT) X-Received: by 10.99.119.4 with SMTP id s4mr12188042pgc.377.1508780404500; Mon, 23 Oct 2017 10:40:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508780404; cv=none; d=google.com; s=arc-20160816; b=XG9Ks7855ypN03AQeoryEcYtAaDk/7ofYt67I3biyqALAFcm4FOt2ecFRg2ygzMfp1 L5vKTJ7Is2IzVaZ7jD7Nt5nC6YWmqeMEwED+LcnEH5v5bpOALOMmETW5PPEDlCTN4j24 ItQcIoiHTy2SwuIB8EjLJWtKWEB8HLuSLuPwEYPRRe9vCkff60NkKPDXkDQp/NdVZLoE bn8OkoCoPyWM+sHJ6wJHWVAQ4nHY9cbfuJC+10LjFqaK2eHvdCyYlzL1uAJRb3xvLfTD ExzQO2zLP66MN315F+1w7pdnKKbSxYqXFyR6Vxfmm4XjgzrNw3o12s1xp4+ceFCT1O3m umxA== 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=ubtdTYdKpSnjoyJhbfvG5tIIKRqzVShV8l2VMNZczmE=; b=sRmcdmqTbJA9nELJ0ZoyEXtd5G+h1NCHpWP7J3jjhmjRl0U6JdmLgdgQZxOrTdb0wc 7R6KiY2v+3ElCxPrsLcKsxCqOwQ3hmYGKoe1J91JKL/ksiX4qz51x/PgjKBEnXJ7Rz2l b8zl8ohPjiddbcmOOUvMENIGtEQHdweYAVCryvxzrRkkVnMdqe5n3GzhZpYLKX0ZSR/N cHAMBXIJQ647NYPA3qFtEOzeSe9ZhaoBwDv4/ueFJoPnd3QSk3hBCRXi/To04IvK5Hvn My9yp5QhR3BGitRIg8pg9HO8xnOBuTzLGZO8IYj+nHYg+aih1Cmn6Imv2QCxGwMFBYqg yuoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=yZlP5dV/; spf=pass (google.com: domain of gcc-patches-return-464873-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464873-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 f15si5628525pfd.511.2017.10.23.10.40.04 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:40:04 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464873-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=yZlP5dV/; spf=pass (google.com: domain of gcc-patches-return-464873-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464873-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=W4q1R8hwoagFcZKr+1CYJAPaYDhbx 2LYoiDlvxCtm+2Btvigl8TfPdcjT4Wj08IdNPF+my3ZxeiHKgb+HWsAEIZyefl22 bEyBHnuEO3Yoqkz/lx0P5EIjKKqJ0UFqzteFpVqoyo6faakE9Yv1Rga5HqLu02VV 5PyrF8J3Z1/Iaw= 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=wCslR80TPFPrQ6nAMdK7SIhqIGA=; b=yZl P5dV/r6pPO2Fm465ijlMYRkee0+3ODPKoYy1maJlsUYb2UiBqQskb2BPxji8UWzN E35dmNnxZbsNPHWG8VHGKDRvWMjSdRzpvC+Pp6d97G/b7MNXoRGyoo+npW8OZaAW 7ZyfGbcWpZM5VOX79jq6wehgTUysvjAn2EVeS2YE= Received: (qmail 116446 invoked by alias); 23 Oct 2017 17:39:48 -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 116437 invoked by uid 89); 23 Oct 2017 17:39:47 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.3 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=Cancel, 097, HX-Received:10.223.157.11, Width X-HELO: mail-wr0-f178.google.com Received: from mail-wr0-f178.google.com (HELO mail-wr0-f178.google.com) (209.85.128.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:39:46 +0000 Received: by mail-wr0-f178.google.com with SMTP id y9so5996777wrb.2 for ; Mon, 23 Oct 2017 10:39:45 -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=ubtdTYdKpSnjoyJhbfvG5tIIKRqzVShV8l2VMNZczmE=; b=tivUnTNx4Y5PhNPovVEWCoqzRmhAkwf0wjf5OZ9GjslUvYurQ2t3cJ/IBhVwYeMFqA E75CjfhTpKf4KwTeOK7XkLNH2CNwlphjfEEh7or/31LIUkYnLfYoHYatqP9YDjFYLL5w 4VhtrxU0WCgYA1WWc0uguO5iUphHiZLqrf5RKxBYvOBW2yYixxGmGo9oQD+4b2uHbAxU NREGRufHovgtd0E1xgcsSWVoTLRLtWaY8nS4Z/DC5Z8IZucSfQX8sfMFpCAtt6nUgJ1F 5LNEb3Jyyf+yyOy/tOW7AUI/RTp6SZ9DEgrDQXhiPWnJ/tvhwoSxQADLZdlupdvJw+is 3WWQ== X-Gm-Message-State: AMCzsaWcZ/5dv+7U725MsfbfT0W+eWrTC2yHvWT+S22reoEZG4m0lvPi QJn2kJGlA8YrVefuGEY5Y5Jx/YZjQuY= X-Google-Smtp-Source: ABhQp+TuWHOTh6SBG+x+KOKuT0cxQkJkmmtW1bFi6FDt7Aj+vmkizX2tlDYmYN5MtNerU/DBezlcAA== X-Received: by 10.223.157.11 with SMTP id k11mr6583507wre.281.1508780383848; Mon, 23 Oct 2017 10:39:43 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id f84sm3248124wme.44.2017.10.23.10.39.42 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:39:43 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [097/nnn] poly_int: alter_reg References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:39:42 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <8760b5epb5.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes alter_reg cope with polynomial mode sizes. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * reload1.c (spill_stack_slot_width): Change element type from unsigned int to poly_uint64_pod. (alter_reg): Treat mode sizes as polynomial. Index: gcc/reload1.c =================================================================== --- gcc/reload1.c 2017-10-23 17:25:38.242865029 +0100 +++ gcc/reload1.c 2017-10-23 17:25:44.492640380 +0100 @@ -200,7 +200,7 @@ #define spill_indirect_levels \ static rtx spill_stack_slot[FIRST_PSEUDO_REGISTER]; /* Width allocated so far for that stack slot. */ -static unsigned int spill_stack_slot_width[FIRST_PSEUDO_REGISTER]; +static poly_uint64_pod spill_stack_slot_width[FIRST_PSEUDO_REGISTER]; /* Record which pseudos needed to be spilled. */ static regset_head spilled_pseudos; @@ -2142,10 +2142,10 @@ alter_reg (int i, int from_reg, bool don { rtx x = NULL_RTX; machine_mode mode = GET_MODE (regno_reg_rtx[i]); - unsigned int inherent_size = PSEUDO_REGNO_BYTES (i); + poly_uint64 inherent_size = GET_MODE_SIZE (mode); unsigned int inherent_align = GET_MODE_ALIGNMENT (mode); machine_mode wider_mode = wider_subreg_mode (mode, reg_max_ref_mode[i]); - unsigned int total_size = GET_MODE_SIZE (wider_mode); + poly_uint64 total_size = GET_MODE_SIZE (wider_mode); unsigned int min_align = GET_MODE_BITSIZE (reg_max_ref_mode[i]); poly_int64 adjust = 0; @@ -2174,10 +2174,15 @@ alter_reg (int i, int from_reg, bool don { rtx stack_slot; + /* The sizes are taken from a subreg operation, which guarantees + that they're ordered. */ + gcc_checking_assert (ordered_p (total_size, inherent_size)); + /* No known place to spill from => no slot to reuse. */ x = assign_stack_local (mode, total_size, min_align > inherent_align - || total_size > inherent_size ? -1 : 0); + || may_gt (total_size, inherent_size) + ? -1 : 0); stack_slot = x; @@ -2189,7 +2194,7 @@ alter_reg (int i, int from_reg, bool don adjust = inherent_size - total_size; if (maybe_nonzero (adjust)) { - unsigned int total_bits = total_size * BITS_PER_UNIT; + poly_uint64 total_bits = total_size * BITS_PER_UNIT; machine_mode mem_mode = int_mode_for_size (total_bits, 1).else_blk (); stack_slot = adjust_address_nv (x, mem_mode, adjust); @@ -2203,9 +2208,10 @@ alter_reg (int i, int from_reg, bool don /* Reuse a stack slot if possible. */ else if (spill_stack_slot[from_reg] != 0 - && spill_stack_slot_width[from_reg] >= total_size - && (GET_MODE_SIZE (GET_MODE (spill_stack_slot[from_reg])) - >= inherent_size) + && must_ge (spill_stack_slot_width[from_reg], total_size) + && must_ge (GET_MODE_SIZE + (GET_MODE (spill_stack_slot[from_reg])), + inherent_size) && MEM_ALIGN (spill_stack_slot[from_reg]) >= min_align) x = spill_stack_slot[from_reg]; @@ -2221,16 +2227,21 @@ alter_reg (int i, int from_reg, bool don if (partial_subreg_p (mode, GET_MODE (spill_stack_slot[from_reg]))) mode = GET_MODE (spill_stack_slot[from_reg]); - if (spill_stack_slot_width[from_reg] > total_size) - total_size = spill_stack_slot_width[from_reg]; + total_size = ordered_max (total_size, + spill_stack_slot_width[from_reg]); if (MEM_ALIGN (spill_stack_slot[from_reg]) > min_align) min_align = MEM_ALIGN (spill_stack_slot[from_reg]); } + /* The sizes are taken from a subreg operation, which guarantees + that they're ordered. */ + gcc_checking_assert (ordered_p (total_size, inherent_size)); + /* Make a slot with that size. */ x = assign_stack_local (mode, total_size, min_align > inherent_align - || total_size > inherent_size ? -1 : 0); + || may_gt (total_size, inherent_size) + ? -1 : 0); stack_slot = x; /* Cancel the big-endian correction done in assign_stack_local. @@ -2241,7 +2252,7 @@ alter_reg (int i, int from_reg, bool don adjust = GET_MODE_SIZE (mode) - total_size; if (maybe_nonzero (adjust)) { - unsigned int total_bits = total_size * BITS_PER_UNIT; + poly_uint64 total_bits = total_size * BITS_PER_UNIT; machine_mode mem_mode = int_mode_for_size (total_bits, 1).else_blk (); stack_slot = adjust_address_nv (x, mem_mode, adjust);