public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jan Hubicka <hubicka@ucw.cz>
To: Richard Biener <rguenther@suse.de>
Cc: gcc-patches@gcc.gnu.org, d@dcepelik.cz
Subject: Re: Make nonoverlapping_component_refs work with duplicated main variants
Date: Tue, 09 Jul 2019 12:41:00 -0000	[thread overview]
Message-ID: <20190709123124.rdelfgb5gkdebdr4@kam.mff.cuni.cz> (raw)
In-Reply-To: <alpine.LSU.2.20.1907091402510.2976@zhemvz.fhfr.qr>

> 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?

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.
> 
> > +      /* 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.

This is stronger than the get_base_ref_and_extend based check in
presence of non-constant ARRAY_REFs.

Honza

  reply	other threads:[~2019-07-09 12:31 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-08  7:39 Jan Hubicka
2019-07-08  9:10 ` Richard Biener
2019-07-08 10:48   ` Jan Hubicka
2019-07-09 12:02   ` Jan Hubicka
2019-07-09 12:21     ` Richard Biener
2019-07-09 12:41       ` Jan Hubicka [this message]
2019-07-09 12:52         ` Richard Biener
2019-07-09 13:10           ` Jan Hubicka
2019-07-09 13:30             ` Richard Biener
2019-07-09 13:37       ` Jan Hubicka
2019-07-09 13:41         ` Richard Biener
2019-07-09 21:03           ` Bernhard Reutner-Fischer
2019-07-11  8:29     ` Rainer Orth
2019-07-16  9:30       ` Jan Hubicka
2019-07-16 11:58         ` Rainer Orth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190709123124.rdelfgb5gkdebdr4@kam.mff.cuni.cz \
    --to=hubicka@ucw.cz \
    --cc=d@dcepelik.cz \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=rguenther@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).