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