From patchwork Mon Oct 23 17:23:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116799 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4888317qgn; Mon, 23 Oct 2017 10:23:30 -0700 (PDT) X-Received: by 10.99.181.67 with SMTP id u3mr12509080pgo.118.1508779410826; Mon, 23 Oct 2017 10:23:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508779410; cv=none; d=google.com; s=arc-20160816; b=yL/DsqFmSCZXzYzMyVKMVggGBXFbU14I/LwlvI//CrA45Iu/jAVg5tfBRrmMUSFP/L xoDz8SI4cMDMTMGAeUN8xyKI84dp1ElBLXoxZu5oCiOItMRksNtc68ZwoUFLD+5CKD+3 UH9O92y5o7PVZecWc6dhnJS0W5DE/BhEW69jwHSE85IusMHRXoTSX2rNCA/fxVkXHHGn qc4WVU76/uWAxovRzc33HPWX/Fw7nMRf2i1N11/EvnukqjSldnol6nHziB1X77oVY63Q yzM6dtkw9SvT6vH6neYLyeSVO9mDLBEWdb7aaOHn5SbX07Aid5N1Y8LF/ks2cFzjFq92 +t9g== 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=WLP2WdScqLO56pK7iffvYdOK6/q202R6baojzkwcdhc=; b=kNLFxJXrvysZlFWdo6+Sswg+4EuctBRF6AHi+ajnc9FoFtE9zCWU08//Z1m+sF2eXh khwAMS9PeLmdUu7773i5yZfCrni7bMc1GKlGezqbf7CIflwFFfB5ulIWfmVa8hpw5+x0 Xe/uSmEBfGhFkgmBKfpxHl0Xi8QVia55O6adhAPvhiTxUV9gBIzxP6fYtMLfdU7IYxNi AVSWwLVmYa/VaZ3tZc2ZRlbec1dG704587v9wZJdoo47r+AFafz5WRlk1sA8bpxz0Lkn ctNgJXZBHDN61Nk8CumSuokd1KAYBPCoJnfDnfaSc46lzq+SPSRyJweXxv6aJpVvUl+1 UIjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qiiKPl/m; spf=pass (google.com: domain of gcc-patches-return-464831-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464831-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 u63si5113875pgd.551.2017.10.23.10.23.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:23:30 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464831-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=qiiKPl/m; spf=pass (google.com: domain of gcc-patches-return-464831-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464831-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=gKvlMk/AphiWcVhJTQ0K555fHILo5 jqLD73AGgHwwjqvO5ZxMDzRHs/jpVZTQ7MErkNmai/90vmigbz7VEhVDiiONYuGC u8psqyTZ/RE3KIwcSeEt8Z24/WjGE/ta/SOLM98O7UdvLSs2mgDcKmuyfkFxOqOI huKjnQzYDivIpE= 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=lMkqanbZoBl2E+WlGI5rs7GAyZo=; b=qii KPl/mGVD7Ome8WV5jLY/6q4YXVLrkgEHhcEeWYS32t1qBFyNXzrgSH1vPQxPVDhN 5fRVZV0b8DkcKQChKZTiCfbvTMeKTch6j6Z3KQq7MJnls/dYjZW4EpSgDViBMI7K z4JKdW8AmxbCcD/ZmEOKrfRoKOfCp7V1TIqezzOU= Received: (qmail 52162 invoked by alias); 23 Oct 2017 17:23:17 -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 52146 invoked by uid 89); 23 Oct 2017 17:23:16 -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= X-HELO: mail-wr0-f169.google.com Received: from mail-wr0-f169.google.com (HELO mail-wr0-f169.google.com) (209.85.128.169) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:23:15 +0000 Received: by mail-wr0-f169.google.com with SMTP id r79so18176879wrb.13 for ; Mon, 23 Oct 2017 10:23:15 -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=WLP2WdScqLO56pK7iffvYdOK6/q202R6baojzkwcdhc=; b=Ab40a06mF7MARLWd0IncENWUc/qg16ajprae59H2kLb6ZGiMp5OoqFVlv46KRbrUZn CG12uaLB7BAu/4lvO9ST37i+LsAE0KZrjCWgFpIIYEhhCHhcvkdcZSNdVN08cr2eKvxf pRSeaHUgWPvYQIV7QPXXM0VQlJDHkVUfXfLGF9g+t+OA1PcLery43qk0EbU6UCiyaADS jb6tymEohPWBWAUST3pRUKJmWw50mjcRoWQX6X0FNrx+7slSvUeb2Fd82HxRamKE/4mJ y09AhvYqdFniJH1TrcVTYiTWWOlJW6dSKbtqmIR5UFxcJq4VRphxHCDRnDt4xAJogSM2 7pgw== X-Gm-Message-State: AMCzsaUfTS4sKlCHcwWHqi3JcBHYwqJsGwP+LC6B0qkdLdm2ChH14QLk /99oAOLJPgfRRI2K5+zf0pX/T0jTvzc= X-Google-Smtp-Source: ABhQp+R313Npn7QS9ns4g99/ip09t+NIAy9tY65hpRrJVCPVXqytglyqakme51OtHh91mNSWKTuV8Q== X-Received: by 10.223.155.208 with SMTP id e16mr2067927wrc.161.1508779393278; Mon, 23 Oct 2017 10:23:13 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id x70sm3307307wmf.0.2017.10.23.10.23.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:23:12 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [055/nnn] poly_int: find_bswap_or_nop_load References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:23:11 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87a80hlqww.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch handles polynomial offsets in find_bswap_or_nop_load, which could be useful for constant-sized data at a variable offset. It is needed for a later patch to compile. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * tree-ssa-math-opts.c (find_bswap_or_nop_load): Track polynomial offsets for MEM_REFs. Index: gcc/tree-ssa-math-opts.c =================================================================== --- gcc/tree-ssa-math-opts.c 2017-10-23 17:18:47.667056920 +0100 +++ gcc/tree-ssa-math-opts.c 2017-10-23 17:22:16.929564362 +0100 @@ -2122,35 +2122,31 @@ find_bswap_or_nop_load (gimple *stmt, tr if (TREE_CODE (base_addr) == MEM_REF) { - offset_int bit_offset = 0; + poly_offset_int bit_offset = 0; tree off = TREE_OPERAND (base_addr, 1); if (!integer_zerop (off)) { - offset_int boff, coff = mem_ref_offset (base_addr); - boff = coff << LOG2_BITS_PER_UNIT; + poly_offset_int boff = mem_ref_offset (base_addr); + boff <<= LOG2_BITS_PER_UNIT; bit_offset += boff; } base_addr = TREE_OPERAND (base_addr, 0); /* Avoid returning a negative bitpos as this may wreak havoc later. */ - if (wi::neg_p (bit_offset)) + if (may_lt (bit_offset, 0)) { - offset_int mask = wi::mask (LOG2_BITS_PER_UNIT, false); - offset_int tem = wi::bit_and_not (bit_offset, mask); - /* TEM is the bitpos rounded to BITS_PER_UNIT towards -Inf. - Subtract it to BIT_OFFSET and add it (scaled) to OFFSET. */ - bit_offset -= tem; - tem >>= LOG2_BITS_PER_UNIT; + tree byte_offset = wide_int_to_tree + (sizetype, bits_to_bytes_round_down (bit_offset)); + bit_offset = num_trailing_bits (bit_offset); if (offset) - offset = size_binop (PLUS_EXPR, offset, - wide_int_to_tree (sizetype, tem)); + offset = size_binop (PLUS_EXPR, offset, byte_offset); else - offset = wide_int_to_tree (sizetype, tem); + offset = byte_offset; } - bitpos += bit_offset.to_shwi (); + bitpos += bit_offset.force_shwi (); } if (!multiple_p (bitpos, BITS_PER_UNIT, &bytepos))