From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@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 17:23:00 -0000 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 Content-Type: text/plain X-SW-Source: 2017-10/txt/msg01556.txt.bz2 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))