From patchwork Mon Oct 23 17:33:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116828 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4897383qgn; Mon, 23 Oct 2017 10:33:50 -0700 (PDT) X-Received: by 10.159.207.149 with SMTP id z21mr10220874plo.164.1508780030303; Mon, 23 Oct 2017 10:33:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508780030; cv=none; d=google.com; s=arc-20160816; b=Bpd/S8kNL9oJtjrp8j40+PKRdPno1kFZuceFUsxMub8UqUW06nYe0v3Z2hcwxCze06 Yuv/yMfX+JXRBFLvXtKuatgI7GP6t+gk7fu/17Cm+UlhBA+XxlPj+Z9vF2H1r6txpsjB cOLJvMgzn/aEzxhDDboCSRhHc6amP1fE/vTboAr5i45KyzvS46ABkjIfz27/m/FxGD/x OoAPW0tCfH8vivJJwRsMm/YiBjhLEAV2iWPX0k/Hr4YxAiNuXQBK8fqMcx/UW9uVgP0H SgC/eZFVVkeHxMtIzoxk733Um8ccnt0KVDyIRHvBg4VhNzpg2+6SxFLj/EQS1o3wnj1K NDuw== 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=EmvD9SuoN5jcBv1I421tzxK/kteiW6DDanlncFmNDVI=; b=o0ag/WV+wiePvGXpbiEPlVl/Ap14bNH/jbyCFl/Me6XbRDm+/atrDEOlJ5xkvbXlX2 fNlZe6yoNwwoEXejW0ploZyh+HkIa++z+N+hvWI7gGHvt5EuWK5JdKYgPGPvWBmWoCrI Zmm6NIIVVe4nPtftKKw8I2ED5A0tDGDRzb28hxPLY2dFbGIJOr7cf3nuSVBjL8js7Q2J TZf4keQ667BVqj06bv4wACaRaNZs4UldJROkTXH27YZZbBmVGlYWR5y2oZcRQI2LGUH2 cFEaYPU9Ja1rh6dUuyDCFCrMmQQr8CBy/cXvVj89xJVYzXzrm4sNpjdT53pxkHuAdBLB S6jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=CTC8QDu+; spf=pass (google.com: domain of gcc-patches-return-464859-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464859-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 b3si5107256pgt.534.2017.10.23.10.33.50 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:33:50 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464859-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=CTC8QDu+; spf=pass (google.com: domain of gcc-patches-return-464859-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464859-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=N3XTx/TiXWnvkY68B3qK7AX9b64EH XQCF1er/q/kazIUUHaOy24t428ff/huS1qYadNdoLrfoeEQ9uuUi5nJtbIIF5QWo zYrlAnHB+AOh5yAys8/ztRJS8sRKBSK0OvqZ5RTex8ytyiNTCbCGWHhDM3+rdfrY piYCrd3oR1iEsE= 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=9YbXZ8XhcqH9pxLf2RIdoS8fC54=; b=CTC 8QDu+ikwV142M1eMj7E2VywjI+tug/SiS3KEbceK/t3WlJ1OGoO7o27w+HSkyZHp eM+vUTRBU3hLbTUXBtorkKRnErePSXJEsS84R8eiJmUdFpc6qGQFSkN7cBwJon/0 2yZ2l864zZxzqi+JvmjUX7OdsB6heBsztFZU1hRw= Received: (qmail 57351 invoked by alias); 23 Oct 2017 17:33:37 -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 56948 invoked by uid 89); 23 Oct 2017 17:33:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-15.8 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f52.google.com Received: from mail-wm0-f52.google.com (HELO mail-wm0-f52.google.com) (74.125.82.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:33:33 +0000 Received: by mail-wm0-f52.google.com with SMTP id q132so11296922wmd.2 for ; Mon, 23 Oct 2017 10:33:33 -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=EmvD9SuoN5jcBv1I421tzxK/kteiW6DDanlncFmNDVI=; b=uPrM1h6P5IcoEY3m/69BTKuugbkTyMdpz4Eyk+Uz0ySzbWZXrrAxnITdiD6BkSlRWm nMGhV7Lzf02ughyYlaErno5H74SJhWFEPayeGWHAtL2m31LCWUP8CmiqWaIGoUa55ysL W8wBSjVFsgr9z/G8EvNC9F82e/W/P7/ATYnvaQLel1i0fA159X45+Y5nPJA2qPdQZoBx RbHIV8FCAD2Ax9S332yIr4me2pQBG9Q492WUm4MoAFtQbiBhsSr0hDkpMsy0Grm9lITj +6fhe2glMUubu9rC+/r7drm1aRk09RsG/vEWXEQNnSSnGPUEG9ScZ0/F/7LoRRlDW45z GqkQ== X-Gm-Message-State: AMCzsaWoksin1K+yziEfLNR6kvqe63MX5yMnrK3TdPO/XL0f8IuRz5fl PMNb5OLWmOJ0db9N8Jgc84EJ6uC6TjY= X-Google-Smtp-Source: ABhQp+S43HwoWgfdxEdmy7v0OaN3xygGPYsSwb6gpNqEJNkPX4q/3zxTuXLXq0J+oZAT3ZGwUD1a9w== X-Received: by 10.28.46.210 with SMTP id u201mr5994965wmu.64.1508780011572; Mon, 23 Oct 2017 10:33:31 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id m37sm8589260wrm.4.2017.10.23.10.33.30 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:33:30 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [083/nnn] poly_int: fold_indirect_ref_1 References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:33:30 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87wp3lg45x.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes fold_indirect_ref_1 handle polynomial offsets in a POINTER_PLUS_EXPR. The specific reason for doing this now is to handle: (tree_to_uhwi (part_width) / BITS_PER_UNIT * TYPE_VECTOR_SUBPARTS (op00type)); when TYPE_VECTOR_SUBPARTS becomes a poly_int. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * fold-const.c (fold_indirect_ref_1): Handle polynomial offsets in a POINTER_PLUS_EXPR. Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2017-10-23 17:20:50.881679906 +0100 +++ gcc/fold-const.c 2017-10-23 17:22:48.984540760 +0100 @@ -14137,6 +14137,7 @@ fold_indirect_ref_1 (location_t loc, tre { tree sub = op0; tree subtype; + poly_uint64 const_op01; STRIP_NOPS (sub); subtype = TREE_TYPE (sub); @@ -14191,7 +14192,7 @@ fold_indirect_ref_1 (location_t loc, tre } if (TREE_CODE (sub) == POINTER_PLUS_EXPR - && TREE_CODE (TREE_OPERAND (sub, 1)) == INTEGER_CST) + && poly_int_tree_p (TREE_OPERAND (sub, 1), &const_op01)) { tree op00 = TREE_OPERAND (sub, 0); tree op01 = TREE_OPERAND (sub, 1); @@ -14208,15 +14209,12 @@ fold_indirect_ref_1 (location_t loc, tre && type == TREE_TYPE (op00type)) { tree part_width = TYPE_SIZE (type); - unsigned HOST_WIDE_INT max_offset + poly_uint64 max_offset = (tree_to_uhwi (part_width) / BITS_PER_UNIT * TYPE_VECTOR_SUBPARTS (op00type)); - if (tree_int_cst_sign_bit (op01) == 0 - && compare_tree_int (op01, max_offset) == -1) + if (must_lt (const_op01, max_offset)) { - unsigned HOST_WIDE_INT offset = tree_to_uhwi (op01); - unsigned HOST_WIDE_INT indexi = offset * BITS_PER_UNIT; - tree index = bitsize_int (indexi); + tree index = bitsize_int (const_op01 * BITS_PER_UNIT); return fold_build3_loc (loc, BIT_FIELD_REF, type, op00, part_width, index); @@ -14226,8 +14224,8 @@ fold_indirect_ref_1 (location_t loc, tre else if (TREE_CODE (op00type) == COMPLEX_TYPE && type == TREE_TYPE (op00type)) { - tree size = TYPE_SIZE_UNIT (type); - if (tree_int_cst_equal (size, op01)) + if (must_eq (wi::to_poly_offset (TYPE_SIZE_UNIT (type)), + const_op01)) return fold_build1_loc (loc, IMAGPART_EXPR, type, op00); } /* ((foo *)&fooarray)[1] => fooarray[1] */