From patchwork Fri Jan 26 13:25:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 125969 Delivered-To: patch@linaro.org Received: by 10.46.84.92 with SMTP id y28csp333810ljd; Fri, 26 Jan 2018 05:26:13 -0800 (PST) X-Google-Smtp-Source: AH8x226lh6cVTDX9HASlt/SZh0kq8AcJfm70hkvXUGc+m68dXBgVibxPcRrv0Yk3o6zZuJb4b4xD X-Received: by 10.99.191.15 with SMTP id v15mr15843783pgf.216.1516973173365; Fri, 26 Jan 2018 05:26:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516973173; cv=none; d=google.com; s=arc-20160816; b=zacjr1EUbam/aKYUUgwmshjetjOWTjmEmL7dDEP378lfKydZRf6WuHON4ossJ4YNkk FndW1zZdET4bfXBdLS/mEC3vZyDjgg9r5uqKG02dilrquBBt8Hs1RvVOCA87SGpcGIT6 /a66uM09i3bpgC48T7ySe69L94bUhw2AyhmX65SGdJBkOsrZxvGZPb/IsiIuyojifG1c xKzotEAMc+LGMTSvGU0ZPyVomsLzz4JXCBVn7a1oW/PJdkKPPqOuj2ZQKOnOs8L0WArt 1K1pDKVbBg3yuX1zFHbnCI4fAsyuFFlifTo6WZROM6qo+XReSerdQKVqcMqlZYUBmEX0 LNEA== 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=vPBeyvCFLtX/tEvdPXTReYhRDuI7kJzT3luMzV3xvcM=; b=vQGkuuW0CjAJrnF+x3TiCFWaWBWn+Q2RWh71BVRySeR3ky0up21ETM4WG2j5CRhkyU NvrMx6iOp/tq1MH6poNfZKfIK/DDyAe9i6NLcyHy5X3BsqazLCES53hk9RF2EVC73t2f 6RxZW9UUXWBt++8VsYobtd00gmBRtWJAXcp5nyKhopYgpFLi90rvnmb0TlDhN53fW5K5 1vxvDpEBZacPybeFqtRNqXy2W6HusyjPdFYpY/RDJ4Z1CIdMd6gIvOkNsc7Rvk/RyqrD pOUOLQkTW+DBzA6LF2jmCgKHR8Pg3WZzR250ThzCYOHc3xfW6kzMfam7HxcvkUVUjleR KbQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=BzYwH0Pz; spf=pass (google.com: domain of gcc-patches-return-472098-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-472098-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 c200si6336014pfb.301.2018.01.26.05.26.12 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 26 Jan 2018 05:26:13 -0800 (PST) Received-SPF: pass (google.com: domain of gcc-patches-return-472098-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=BzYwH0Pz; spf=pass (google.com: domain of gcc-patches-return-472098-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-472098-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=f+buZNMidtKxq90drzuim0X9DbLO98RdGFCMYVa5OgOd5tt6ub4oh 1VF10lAaGz/p0euVTVuVHSPrLnDKfxcHj6lc7VbXxFHzK+q+Yr/+5bxuYne6npJJ fVd4LNKoWKMzqspk5I+OQ+/GXmhXITGuL9EFCA6Dtt8FhBeg3+fzLI= 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=FQfrHh652nQ7HWxU5Osn2WD0M2w=; b=BzYwH0PziyLLbsP8noKK 2Bs2/QVkyELVNEANoSOHR/YlVIbHTeGp8krXiuR5oSzHmR+4bEavp93444HYfGRX DdMYl+9QcUbOxjc04oTrct8JisgyFVR1VuGo74J1k09yf+OzzSbykcW6ByYMXDV6 xbSZJebECufvkDQh5zTkDMo= Received: (qmail 126966 invoked by alias); 26 Jan 2018 13:25:59 -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 126931 invoked by uid 89); 26 Jan 2018 13:25:57 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy=Hx-languages-length:2683 X-HELO: mail-wm0-f50.google.com Received: from mail-wm0-f50.google.com (HELO mail-wm0-f50.google.com) (74.125.82.50) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 26 Jan 2018 13:25:55 +0000 Received: by mail-wm0-f50.google.com with SMTP id v123so21198725wmd.5 for ; Fri, 26 Jan 2018 05:25:55 -0800 (PST) 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=vPBeyvCFLtX/tEvdPXTReYhRDuI7kJzT3luMzV3xvcM=; b=OXD5wWgua+dH1frDq8qVTdei3BGPNBL5H+uridLN/Y4Mx1WtYBcGSdPXX49NSTd4+k QKpc4JtgbbA0nMd4BVLckWkayZH8YuRTV2xW+s0VcBbCUiRDJyJTZNMJKX5/SSAFekuW Mew+RNW4jUH+w3ItAhjS8JZfFAl3WpPbzL+cVjpHns+ia5kq6xtZUTRhkEXX2pCMaOX6 HjQXYXyNmIc5cmSRBXXqq4z2kTdH9Gneh7JMys4LrzT93q53kyCEs1lQues+kepvuVmG vW+rrWKwQmYmDiUsl9LZGiZe57ZSfmyIVbr1m2WAyOQKAZ9sMjN4p+BdKAAnNBL+Tx3s 5Lyg== X-Gm-Message-State: AKwxytfFpv1SX9RtuaIRCNTO9Wy92mI+8OnfAVwL2NHCoSBCHm8Qc3Iy 3ccfPpRswguBMOytSVq887NEbR4C4M0= X-Received: by 10.28.138.146 with SMTP id m140mr4933851wmd.85.1516973153702; Fri, 26 Jan 2018 05:25:53 -0800 (PST) Received: from localhost (92.40.248.158.threembb.co.uk. [92.40.248.158]) by smtp.gmail.com with ESMTPSA id d17sm2166384wrc.19.2018.01.26.05.25.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Jan 2018 05:25:53 -0800 (PST) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: Fix LRA subreg calculation for big-endian targets Date: Fri, 26 Jan 2018 13:25:51 +0000 Message-ID: <87inbopx9c.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 LRA was using a subreg offset of 0 whenever constraints matched two operands with different modes. That leads to an invalid offset (and ICE) on big-endian targets if one of the modes is narrower than a word. E.g. if a (reg:SI X) is matched to a (reg:QI Y), the big-endian subreg should be (subreg:QI (reg:SI X) 3) rather than (subreg:QI (reg:SI X) 0). But this raises the issue of what the behaviour should be when the matched operands occupy different numbers of registers. Should the register numbers match, or should the locations of the lsbs match? Although the documentation isn't clear, reload went for the second interpretation (which seems the most natural to me): /* On a REG_WORDS_BIG_ENDIAN machine, point to the last register of a multiple hard register group of scalar integer registers, so that for example (reg:DI 0) and (reg:SI 1) will be considered the same register. */ So I think this means that we can/must use the lowpart offset unconditionally, rather than trying to separate out the multi-register case. This also matches the LRA handling of constant integers, which already uses lowpart subregs. The patch fixes gcc.target/aarch64/sve/extract_[34].c for aarch64_be. Tested on aarch64_be-none-elf, aarch64-linux-gnu and x86_64-linux-gnu. OK to install? 2018-01-26 Richard Sandiford gcc/ * lra-constraints.c (match_reload): Use subreg_lowpart_offset rather than 0 when creating partial subregs. Index: gcc/lra-constraints.c =================================================================== --- gcc/lra-constraints.c 2018-01-20 13:43:02.060083731 +0000 +++ gcc/lra-constraints.c 2018-01-26 13:22:46.350577506 +0000 @@ -945,7 +945,10 @@ match_reload (signed char out, signed ch if (SCALAR_INT_MODE_P (inmode)) new_out_reg = gen_lowpart_SUBREG (outmode, reg); else - new_out_reg = gen_rtx_SUBREG (outmode, reg, 0); + { + poly_uint64 offset = subreg_lowpart_offset (outmode, inmode); + new_out_reg = gen_rtx_SUBREG (outmode, reg, offset); + } LRA_SUBREG_P (new_out_reg) = 1; /* If the input reg is dying here, we can use the same hard register for REG and IN_RTX. We do it only for original @@ -965,7 +968,10 @@ match_reload (signed char out, signed ch if (SCALAR_INT_MODE_P (outmode)) new_in_reg = gen_lowpart_SUBREG (inmode, reg); else - new_in_reg = gen_rtx_SUBREG (inmode, reg, 0); + { + poly_uint64 offset = subreg_lowpart_offset (inmode, outmode); + new_in_reg = gen_rtx_SUBREG (inmode, reg, offset); + } /* NEW_IN_REG is non-paradoxical subreg. We don't want NEW_OUT_REG living above. We add clobber clause for this. This is just a temporary clobber. We can remove