From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 74724 invoked by alias); 9 Jul 2019 12:41:17 -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 74618 invoked by uid 89); 9 Jul 2019 12:41:17 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.8 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 09 Jul 2019 12:41:15 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 29448AD3E; Tue, 9 Jul 2019 12:41:13 +0000 (UTC) Date: Tue, 09 Jul 2019 12:52:00 -0000 From: Richard Biener To: Jan Hubicka cc: gcc-patches@gcc.gnu.org, d@dcepelik.cz Subject: Re: Make nonoverlapping_component_refs work with duplicated main variants In-Reply-To: <20190709123124.rdelfgb5gkdebdr4@kam.mff.cuni.cz> Message-ID: References: <20190708072649.vqd5u6jxsz5ybtt7@kam.mff.cuni.cz> <20190709114917.qva4nb2h7j5vzdur@kam.mff.cuni.cz> <20190709123124.rdelfgb5gkdebdr4@kam.mff.cuni.cz> User-Agent: Alpine 2.20 (LSU 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-SW-Source: 2019-07/txt/msg00690.txt.bz2 On Tue, 9 Jul 2019, Jan Hubicka wrote: > > For consistency yes I guess but IIRC they cannot really appear in > > FIELD_DECLs. > > OK, i tought that if I put SVE into structures, we may end up with > these. > > > + /* Different fields of the same record type cannot overlap. > > > + ??? Bitfields can overlap at RTL level so punt on them. */ > > > + if (DECL_BIT_FIELD (field1) && DECL_BIT_FIELD (field2)) > > > + return 0; > > > + > > > > don't you need the DECL_BIT_FIELD_REPRESENTATIVE check here as well? > > I'd do > > > > if (DECL_BIT_FIELD_REPRESENTATIVE (field1)) > > field1 = DECL_BIT_FIELD_REPRESENTATIVE (field1); > > if (DECL_BIT_FIELD_REPRESENTATIVE (field2)) > > field2 = DECL_BIT_FIELD_REPRESENTATIVE (field2); > > > > thus use the representative for the overlap check. It might > > be the case that we can improve here and if we do this > > can do the DECL_BIT_FIELD check after this (hoping the > > representative doesn't have it set). > > OK. > > > > > + if (tree_int_cst_equal (DECL_FIELD_OFFSET (field1), > > > + DECL_FIELD_OFFSET (field2)) > > > + && tree_int_cst_equal (DECL_FIELD_BIT_OFFSET (field1), > > > + DECL_FIELD_BIT_OFFSET (field2))) > > > + return 0; > > > > In gimple_compare_field_offset this was fast-pathed for > > DECL_OFFSET_ALIGN (f1) == DECL_OFFSET_ALIGN (f2) so I suggest to > > do that here as well. Note that DECL_FIELD_OFFSET can be > > a non-constant which means you cannot use tree_int_cst_equal > > unconditionally here but you have to use operand_equal_p. > > tree_int_cst_equal will return false if offsets are not INTEGER_CST. > I was not sure if I can safely use operand_equal_p. What happens for > fields with variable offsets when I inline two copies of same function > which takes size as parameter and make the size different? Will I get > here proper SSA name so operand_equal_p will work? No, you get a DECL, but yes, I think operand_equal_p will work. Consider two _same_ variable sizes, you'll not see that you have to return zero then? But yes, in case you have types globbed to the canonical type (but not FIELD_DECLs) then you'll get false !operand_equal_p as well. The question is really what is desired here. If you want/need precision for non-constant offsets then you have to look at the COMPONENT_REF trees because the relevant offset (SSA name) is only there (in TREE_OPERAND (component_ref, 2)). If you want to give up for non-constants and can do that without correctness issue then fine (but Ada probably would like to have it - so also never forget to include Ada in testing here ;)) > If so, I still see no point for fast-path for DECL_OFFSET_ALIGN. In many > cases BIT_OFFSET will be just 0, so even if offset alignments are > different we are likely going to hit this fast path avoiding parsing > trees later. Ok. > > > > > + /* Note that it may be possible to use component_ref_field_offset > > > + which would provide offsets as trees. However constructing and folding > > > + trees is expensive and does not seem to be worth the compile time > > > + cost. */ > > > + > > > + poly_uint64 offset1, offset2; > > > + poly_uint64 bit_offset1, bit_offset2; > > > + poly_uint64 size1, size2; > > > > I think you need poly_offset_int here since you convert to bits below. > > > > The gimple_compare_field_offset checking way looks cheaper btw, so > > I wonder why you don't simply call it but replicate things here? > > When do we expect to have partially overlapping field decls? Even > > when considering canonical type merging? > > Because the types I am comparing may not have same canonical types. > > nonoverlapping_component_refs_since_match_p is called when we prove that > base pointers are the same (even with -fno-strict-aliasing). In such > cases the access paths may be based on completely different types. The > point of nonoverlapping_component_refs_since_match_p is to match them as > far as possible when they are semantically equivalent in hope to get > non-overlapping refs in the last step. Oh, OK ... a bit more explaining commentary might be nice (at the top of the function - basically what the input constraints to the FIELD_DECLs are). Btw, the offsets in FIELD_DECLs are relative to DECL_CONTEXT so comparing when DECL_CONTEXT are not related at all doesn't make any sense. Well, unless we know _those_ are at the same offset, so - the constraint for the FIELD_DECLs we compare is that the containing structure type object instances live at the same address? Richard.