From patchwork Mon Oct 23 17:14:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Sandiford X-Patchwork-Id: 116780 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp4880397qgn; Mon, 23 Oct 2017 10:14:55 -0700 (PDT) X-Received: by 10.98.205.68 with SMTP id o65mr13799812pfg.117.1508778895268; Mon, 23 Oct 2017 10:14:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1508778895; cv=none; d=google.com; s=arc-20160816; b=F46lbaMaXc4IiBf76h/Sg/VpI6vZYic7LE+7sI61OZbLXKdBwTOZ8N6cmwt9RPwQeV +RJAwUTb78CCPfJ8UKLUUzDsl/vYsiEcPVd9i/v+EaLbBEBEe80QKKlap2ignjkLakEk AiFwe5stgvxzIPAvI56qE3ofw/PPiX9GX2TJEWHcLq4EN1brj7X20SBun9psJohZ6Sfi Wy9TyonXxTrYBEv69NopTpM/d1GYcmnVz23ZODoL7wQxUW/ch6CAmU6wqYBZQdzEtWH2 0JkUM/TksIQ/InZIdGz/qy3FFKWyTN1FrOclVf/pvpDzvpaqQN36RU6ZaI1ocwENzFMi x1ZA== 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=t1pnIMFi5gHiHKgfdCDnPJTPnWpg6Hv13DySHe/OYkI=; b=xCJZXgkQdW9QwO7qhRcpwkID/T3zTP85DJOOE+C68sERjwrL0MEBTe9/x8yKdLxIcE 8dHaF3ic8KdC1SQMqn+yxLG3eDlYFTHU48u/nMz/zlG0yCSu5T0kuLITyvFXoQk5YErJ 25H4LfHrZqwUHyMcooQNH7KoAr5qRtfiHQQvA2jdMsmypH7ZhSOe7fWlgY/f3EFvT7yj b2YAR3HXg1SRQ/WpvevFjJ5BppcyEYjVvUfo+6LisoT5ecYn1a5/0e3HvtG1NvrU46x4 zW3Lz0rvZ4suhxMwGR5BHdoyVpBsfBIASRIRWTod8IsLxZ5jXP4Fi8H08jj96LvoRwiX OnBg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=E5hxjCoo; spf=pass (google.com: domain of gcc-patches-return-464812-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464812-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 l14si5133665pgc.392.2017.10.23.10.14.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Oct 2017 10:14:55 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-464812-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=E5hxjCoo; spf=pass (google.com: domain of gcc-patches-return-464812-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-464812-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=Qz9VJsUSEEs9oovkVzw40IiYDgMAo v+PndPWap/yAv3WHkiMTNH198smqS27LzhlafnDIqaAXkMmTUX2J47sLNbJq5JgR hICE5wksJMPI031VCYFTz5u3xbJaBmuqNvy9nLnjeq/qvru9XNMUazvrL6/ZsgSl x22PYdSIwD63uI= 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=VfcyA9Wm/5fxL8nPKDNaewR57/A=; b=E5h xjCooBXkCkaUnjK6+cwCPZPZq0dtJCBu5hOWOpQXIXqn9iLiQKlWfYhgkUV2XWhc qPTtGaJ/e5ChGppL5TIWUEJTSkd2S/WjaBEaN7/wP/BdePiYqrj+S5u27fzSLDEc JWVviusHomkpWQtvjL6OR2AyZzmCWBZbXwnS6AR0= Received: (qmail 28667 invoked by alias); 23 Oct 2017 17:14:31 -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 28612 invoked by uid 89); 23 Oct 2017 17:14:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.3 required=5.0 tests=AWL, BAYES_00, 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-wr0-f177.google.com Received: from mail-wr0-f177.google.com (HELO mail-wr0-f177.google.com) (209.85.128.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 23 Oct 2017 17:14:29 +0000 Received: by mail-wr0-f177.google.com with SMTP id k62so18132526wrc.9 for ; Mon, 23 Oct 2017 10:14:28 -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=t1pnIMFi5gHiHKgfdCDnPJTPnWpg6Hv13DySHe/OYkI=; b=RcPwTt2gzG1nYJIP1sgaFNuZ8RIdUqogfO8uYFDUMgl5/dn3wIGlPFrWyN3x/oCEF/ rCOpp2ueGl4ScWY32I2UlD5Dt+IqjHkLA+oLjvKlB55itHMNzy8HcJmyZA2k7Oyv5TNS bEkZIJ/MClhIEaUBHcUXRrg7FSsNVT1acIQ1arLIGxNzms2P47BWB8d9SLtreFJFIneb bXPvZAqXsDy76/+vOTuyWZ8GdIyf2CeMnzWWTBM8ttc7WMYVO7PiFvs3vtMa2HDeSLtb Q4h9AmDdQ4lc18T/Dl8TX2BB6FHCNLOzLHVgbzIunOYtLucVOjyS4PZ0faxLvQc9KNpf k11w== X-Gm-Message-State: AMCzsaUl4RH/XZI1/Eiax3PkWfftYcQHAoVz50gBlZ97G48I8eZXA3tT j3kHVm/PwxPI7HiaBKSvvv35dSP+wNY= X-Google-Smtp-Source: ABhQp+TX8KYSOJMM/Tw8mKMNexOU0ijYeXwhITXCUH7mNo6i2hN71nBr460clXu2cnxh/7nuNwDcbA== X-Received: by 10.223.158.8 with SMTP id u8mr12665057wre.16.1508778866828; Mon, 23 Oct 2017 10:14:26 -0700 (PDT) Received: from localhost ([2.26.27.199]) by smtp.gmail.com with ESMTPSA id v5sm5703974wrf.29.2017.10.23.10.14.25 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2017 10:14:26 -0700 (PDT) From: Richard Sandiford To: gcc-patches@gcc.gnu.org Mail-Followup-To: gcc-patches@gcc.gnu.org, richard.sandiford@linaro.org Subject: [036/nnn] poly_int: get_object_alignment_2 References: <871sltvm7r.fsf@linaro.org> Date: Mon, 23 Oct 2017 18:14:25 +0100 In-Reply-To: <871sltvm7r.fsf@linaro.org> (Richard Sandiford's message of "Mon, 23 Oct 2017 17:54:32 +0100") Message-ID: <87k1zlokge.fsf@linaro.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux) MIME-Version: 1.0 This patch makes get_object_alignment_2 track polynomial offsets and sizes. The real work is done by get_inner_reference, but we then need to handle the alignment correctly. 2017-10-23 Richard Sandiford Alan Hayward David Sherwood gcc/ * builtins.c (get_object_alignment_2): Track polynomial offsets and sizes. Update the alignment handling. Index: gcc/builtins.c =================================================================== --- gcc/builtins.c 2017-10-23 17:11:39.984447382 +0100 +++ gcc/builtins.c 2017-10-23 17:18:42.394520412 +0100 @@ -252,7 +252,7 @@ called_as_built_in (tree node) get_object_alignment_2 (tree exp, unsigned int *alignp, unsigned HOST_WIDE_INT *bitposp, bool addr_p) { - HOST_WIDE_INT bitsize, bitpos; + poly_int64 bitsize, bitpos; tree offset; machine_mode mode; int unsignedp, reversep, volatilep; @@ -377,8 +377,17 @@ get_object_alignment_2 (tree exp, unsign } } + /* Account for the alignment of runtime coefficients, so that the constant + bitpos is guaranteed to be accurate. */ + unsigned int alt_align = ::known_alignment (bitpos - bitpos.coeffs[0]); + if (alt_align != 0 && alt_align < align) + { + align = alt_align; + known_alignment = false; + } + *alignp = align; - *bitposp = bitpos & (*alignp - 1); + *bitposp = bitpos.coeffs[0] & (align - 1); return known_alignment; }