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: Mon, 08 Jul 2019 10:48:00 -0000	[thread overview]
Message-ID: <20190708094327.72wcfah7ezh5pxh5@kam.mff.cuni.cz> (raw)
In-Reply-To: <alpine.LSU.2.20.1907081057430.2976@zhemvz.fhfr.qr>

> > +/* FIELD1 and FIELD2 are two component refs whose bases are either
> > +   both at the same address or completely disjoint.
> > +   Return 1 if FIELD1 and FIELD2 are non-overlapping
> > +   Return 0 if FIELD1 and FIELD2 are having same addresses or are
> > +     completely disjoint.
> 
> completely disjoint?  I guess
> 
>   Return 0 if accesses to FIELD1 and FIELD2 are possibly overlapping.
> 
> is better matching actual behavior.  Likewise mentioning 'accesses'
> in the first because of the bitfield treatment (the fields may
> be non-overlapping but actual accesses might be).

I was trying to describe difference between 0 and -1.
We return 0 when we fully structurally matched the path and we know it
is same. -1 means that we arrived to somehting we can not handle (union,
mismatched offsets) and it would make sense to try disambiguating
further.

Currently it means that in addition to
nonoverlapping_component_refs_since_match_p we also do
nonoverlapping_component_refs_p which has some chance to recover from
the mismatched REF pair, match the types later on path and still
disambiguate.  It seem to happen very rarely though.
> 
> > +      /* 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 -1;
> 
> This is similar as the DECL_BIT_FIELD_REPRESENTATIVE check so why
> return -1 instead of 0?

Well, my plan is to put this test before ref_and_offset which still have
chace to suceed if fields are far away. But i am happy to return 0 here
and mess with that later.
> > +  else 
> > +    {
> > +      if (operand_equal_p (DECL_FIELD_BIT_OFFSET (field1),
> > +			   DECL_FIELD_BIT_OFFSET (field2), 0))
> > +	return 0;
> 
> I think this is overly pessimistic - the offset of a field
> is DECL_FIELD_OFFSET + DECL_FIELD_BIT_OFFSET (the latter is
> only up to DECL_OFFSET_ALIGN, the rest of the constant
> offset spills into DECL_FIELD_OFFSET).  Which also means ...
> 
> > +
> > +      /* 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 -1;
> > +
> > +      poly_uint64 offset1;
> > +      poly_uint64 offset2;
> > +      poly_uint64 size1;
> > +      poly_uint64 size2;
> > +      if (!poly_int_tree_p (DECL_FIELD_BIT_OFFSET (field1), &offset1)
> > +	  || !poly_int_tree_p (DECL_FIELD_BIT_OFFSET (field2), &offset2)
> > +	  || !poly_int_tree_p (DECL_SIZE (field1), &size1)
> > +	  || !poly_int_tree_p (DECL_SIZE (field2), &size2)
> > +	  || ranges_maybe_overlap_p (offset1, size1, offset2, size2))
> 
> this is technically wrong in case we had DECL_FIELD_OFFSETs 4 and 8
> and DECL_FIELD_BIT_OFFSETs 32 and 0.
> 
> So you have to compute the combined offsets first.

OK, I guess I can take look at the get_base_ref_and_offset there. Thanks
for pointing this out.
> 
> > +	return -1;
> 
> I think it may make sense to return -1 if any of the !poly_int_tree_p
> tests fire, but otherwise?  I'm not actually sure what -1 vs. 0
> means here - is 0 a must exactly overlap and -1 is a may overlap
> somehow?

Well, we have two fields that overlap partly from two different types
in >nonoverlapping_component_refs_since_match_p  so it can not
continue walking (since the main invariant is broken)
we may still suceed with the nonoverlaping_component_refs 

Thanks, I will update the patch.
Honza

  reply	other threads:[~2019-07-08  9:43 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 [this message]
2019-07-09 12:02   ` Jan Hubicka
2019-07-09 12:21     ` Richard Biener
2019-07-09 12:41       ` Jan Hubicka
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=20190708094327.72wcfah7ezh5pxh5@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).