From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by sourceware.org (Postfix) with ESMTP id D3FD33857817 for ; Thu, 26 Nov 2020 16:15:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D3FD33857817 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 87CB631B; Thu, 26 Nov 2020 08:15:34 -0800 (PST) Received: from localhost (e121540-lin.manchester.arm.com [10.32.98.126]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 135C43F23F; Thu, 26 Nov 2020 08:15:33 -0800 (PST) From: Richard Sandiford To: Jeff Law Mail-Followup-To: Jeff Law , gcc-patches@gcc.gnu.org, richard.sandiford@arm.com Cc: gcc-patches@gcc.gnu.org Subject: Re: [07/23] Add a class that multiplexes two pointer types References: <25e7106c-bd83-647f-1247-d9ab474a8528@redhat.com> Date: Thu, 26 Nov 2020 16:15:32 +0000 In-Reply-To: <25e7106c-bd83-647f-1247-d9ab474a8528@redhat.com> (Jeff Law's message of "Wed, 25 Nov 2020 13:23:32 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Nov 2020 16:15:36 -0000 Jeff Law writes: > On 11/13/20 1:14 AM, Richard Sandiford via Gcc-patches wrote: >> This patch adds a pointer_mux class that provides similar >> functionality to: >> >> union { T1 *a; T2 *b; }; >> ... >> bool is_b_rather_than_a; >> >> except that the is_b_rather_than_a tag is stored in the low bit >> of the pointer. See the comments in the patch for a comparison >> between the two approaches and why this one can be more efficient. >> >> I've tried to microoptimise the class a fair bit, since a later >> patch uses it extensively in order to keep the sizes of data >> structures down. >> >> gcc/ >> * mux-utils.h: New file. > Do we have any potentially bootstrappable targets where we can't > guarantee pointer alignment of at least 16 bits?=C2=A0 I see what look li= ke > suitable asserts, and presumably if we trigger them, then we're going to > need to rethink this and fall back to a separate bit? Like you say, the asserts should trap that if it happens. I think the fix would be to increase the alignment of the data types involved (which we can now do in a standard way -- probably wouldn't have been possible before the switch to C++11, at least not without using extensions). Thanks, Richard