From patchwork Mon Oct 23 17:17:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116783 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4882865qgn; Mon, 23 Oct 2017 10:17:26 -0700 (PDT) X-Received: by 10.98.205.12 with SMTP id o12mr14030167pfg.339.1508779046812; Mon, 23 Oct 2017 10:17:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508779046; cv=none; d=google.com; s=arc-20160816; b=xr3ZBTz37wv1TTJPOWMMi8A5eHMXIgxA/kkkmvSYPOIdYJCJtSUtq2P2Iq55TB41YN P2EUxzhgwWZR6ZkglX/+EDJrzuS/GyVs/yK9nAEc/nzf/yJgl8EgbfChxR26bk1ZDbt9 Kl61fvIuJdOSlPLil0vipooxwXiasy66NFof2yYluEYNIOrCepo8casyN10S3JQKIKcJ Z3GlcGUP123WOjA80SHjXP6/OqmSfZBUYM3LE5wGx+lSMsIBxkRogCvdEXlHVwNkO7qH NSTxQFQ53ecK9LIM7sTeY5A6k6tHNv4IH+kkkrlB3X441NQKMmS5uGn2z7DDgTPOTieu t70w== 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=J13Bo0CcFh501EaVMk7HQ6czPr999V4ob4O1DWya3nE=; b=JD8Q/Oyt9IeWCiO016TLiBo78eYf8ESyumjAEfAZgS00tifIaybhpkEjQcmYZaZsqY DL7xBOwhPo0E11BvJhDhlNxg6zccDrr2KVzN/+b99AjvA5pF68I+jQSP/zzLPkT+V6/q GUNHFyKWhUKnRf17FXRJOyDQ95Ht7IEKms9DQLTmQGQfnybT1syUxaI/J9WhI+uMMXgn LB7oT+X4c4kM+nK6aBC7XuMvmGL0hN3OK7XKd84R73pVZlfOAtBcWoWepQpeZvXlRhqf BuF/vdCQnTCMYNO/t5WwMqzY3N3q3R9FeFR11kZE4h0HSJ0hUWmGZhKks4hn8+Ylz4IL BkDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=mZzLOAM3; spf=pass (google.com: domain of gcc-patches-return-464815-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464815-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 12si4325662plb.264.2017.10.23.10.17.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:17:26 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464815-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=mZzLOAM3; spf=pass (google.com: domain of gcc-patches-return-464815-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464815-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=FvaqNIQVXIunOgAE3htwHMtPnMrgr aGV77PIehO5SjCyWN5GoM4NjNf+y7CjN19BlxOAQmv46uFHjsF3qFSCpR3Kib3U7 7Sfdb9ZtsS3cFw0CxRG9Prq7G79qAj6t0YuBgg5P8YGC9eXe6KZRpYD12DfVcIBx 4FqdXf7Ayb4X8o= 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=Ziq58JBwHw2Oo7pMOO7KAKuapkQ=; b=mZz LOAM3oyqGMmnXMlNYeKtTcpzmA4batsQLcEXonVWGL+MFBCQXIcMeYObmCknk+ON 4Fb/EmXWaHEjblGkpcH+S4S+VQc9tsUV+Bh6P7s/P+7D8mSi08Hwnypkor9xs26A u327Ly3QEwjV3W5tB3g/fDx9wAHVzARTFrSCjhUg= Received: (qmail 51780 invoked by alias); 23 Oct 2017 17:17:12 -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 51573 invoked by uid 89); 23 Oct 2017 17:17:12 -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-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:17:11 +0000 Received: by mail-wm0-f42.google.com with SMTP id m72so10945433wmc.1 for ; Mon, 23 Oct 2017 10:17:10 -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=J13Bo0CcFh501EaVMk7HQ6czPr999V4ob4O1DWya3nE=; b=mtJZ1fU4tlB+nl2Bdu5MFU5QSio4KZdkUgT22esJWzQ+HCYmaSY0SgAaujp56M1w/5 4DXhd+3Ex5N8UnPmVh14Ip6gdl1fN1X1sAgifMUau8PALPXTPEVyLTq7RCb4LtEhcSPg 3c7EpHd5rt8Bg8i9CzKLLFOdQfrVqBdcOvFcrUI74XniARG7yNu/nRXxmH4XFaudr9qF BGNzz39ioBHQV0Xb5vyBMj7ydHyZlDSRik+dP9FnJ4t0ZCtwWmgAgBfspn9UzoHA6Xo7 IvnhKPMvZErvzejF2NyXm+iP1QQv+TGCvnthICVjBNCJmDM9m/hMln7PIazvMkpE4PCj fZgw== X-Gm-Message-State: AMCzsaXRfQ/7EJlluQqUD+KsfWPrdFlfHSDXxAnBayWnDFpYPErHB9SA WyqB9wE6s5M/318svfXX9SxgXq674To= X-Google-Smtp-Source: ABhQp+TR2ray0A+Yy2fhB8jCRzWFE4N6wO7Be3BizSfQ/pPl+97zQPFGIT90JBh27efNyIlwzg3T3Q== X-Received: by 10.28.143.203 with SMTP id r194mr6412503wmd.39.1508779028854; Mon, 23 Oct 2017 10:17:08 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id k19sm1514973wrg.32.2017.10.23.10.17.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:17:08 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [039/nnn] poly_int: pass_store_merging::execute References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:17:07 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <877evlokbw.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes pass_store_merging::execute track polynomial sizes and offsets. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * gimple-ssa-store-merging.c (pass_store_merging::execute): Track polynomial sizes and offsets. Index: gcc/gimple-ssa-store-merging.c =================================================================== --- gcc/gimple-ssa-store-merging.c 2017-10-23 17:11:39.971422491 +0100 +++ gcc/gimple-ssa-store-merging.c 2017-10-23 17:18:46.178187802 +0100 @@ -1389,7 +1389,7 @@ pass_store_merging::execute (function *f tree lhs = gimple_assign_lhs (stmt); tree rhs = gimple_assign_rhs1 (stmt); - HOST_WIDE_INT bitsize, bitpos; + poly_int64 bitsize, bitpos; machine_mode mode; int unsignedp = 0, reversep = 0, volatilep = 0; tree offset, base_addr; @@ -1399,8 +1399,6 @@ pass_store_merging::execute (function *f /* As a future enhancement we could handle stores with the same base and offset. */ bool invalid = reversep - || ((bitsize > MAX_BITSIZE_MODE_ANY_INT) - && (TREE_CODE (rhs) != INTEGER_CST)) || !rhs_valid_for_store_merging_p (rhs); /* We do not want to rewrite TARGET_MEM_REFs. */ @@ -1413,23 +1411,17 @@ pass_store_merging::execute (function *f PR 23684 and this way we can catch more chains. */ else if (TREE_CODE (base_addr) == MEM_REF) { - offset_int bit_off, byte_off = mem_ref_offset (base_addr); - bit_off = byte_off << LOG2_BITS_PER_UNIT; + poly_offset_int byte_off = mem_ref_offset (base_addr); + poly_offset_int bit_off = byte_off << LOG2_BITS_PER_UNIT; bit_off += bitpos; - if (!wi::neg_p (bit_off) && wi::fits_shwi_p (bit_off)) - bitpos = bit_off.to_shwi (); - else + if (!bit_off.to_shwi (&bitpos)) invalid = true; base_addr = TREE_OPERAND (base_addr, 0); } /* get_inner_reference returns the base object, get at its address now. */ else - { - if (bitpos < 0) - invalid = true; - base_addr = build_fold_addr_expr (base_addr); - } + base_addr = build_fold_addr_expr (base_addr); if (! invalid && offset != NULL_TREE) @@ -1455,13 +1447,19 @@ pass_store_merging::execute (function *f struct imm_store_chain_info **chain_info = m_stores.get (base_addr); - if (!invalid) + HOST_WIDE_INT const_bitsize, const_bitpos; + if (!invalid + && bitsize.is_constant (&const_bitsize) + && bitpos.is_constant (&const_bitpos) + && (const_bitsize <= MAX_BITSIZE_MODE_ANY_INT + || TREE_CODE (rhs) == INTEGER_CST) + && const_bitpos >= 0) { store_immediate_info *info; if (chain_info) { info = new store_immediate_info ( - bitsize, bitpos, stmt, + const_bitsize, const_bitpos, stmt, (*chain_info)->m_store_info.length ()); if (dump_file && (dump_flags & TDF_DETAILS)) { @@ -1490,7 +1488,7 @@ pass_store_merging::execute (function *f /* Start a new chain. */ struct imm_store_chain_info *new_chain = new imm_store_chain_info (m_stores_head, base_addr); - info = new store_immediate_info (bitsize, bitpos, + info = new store_immediate_info (const_bitsize, const_bitpos, stmt, 0); new_chain->m_store_info.safe_push (info); m_stores.put (base_addr, new_chain);