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