From: Richard Guenther <rguenther@suse.de>
To: Eric Botcazou <ebotcazou@adacore.com>
Cc: gcc@gcc.gnu.org
Subject: Re: Type-based alias analysis and alias sets
Date: Fri, 23 Oct 2009 14:04:00 -0000 [thread overview]
Message-ID: <alpine.LNX.2.00.0910231346330.4520@zhemvz.fhfr.qr> (raw)
In-Reply-To: <200910231331.41698.ebotcazou@adacore.com>
On Fri, 23 Oct 2009, Eric Botcazou wrote:
> Hi Richard,
>
> I just (re-)discovered that the new TBAA machinery is quite aggressive and
> breaks cases that used to work in Ada (-O2 testcase for SPARC64 attached).
>
> The problem boils down to this:
>
> D.1416_1 = (struct p__rec &) &r.F;
> r.F = ...
> ... = D.1416_1->d;
>
> DSE computes that the store to r.F is dead and eliminates it at -O2 because
> ultimately nonaliasing_component_refs_p returns false:
>
> /* If we have two type access paths B1.path1 and B2.path2 they may
> only alias if either B1 is in B2.path2 or B2 is in B1.path1. */
> return false;
>
> [Shouldn't nonaliasing_component_refs_p be named aliasing_component_refs_p or
> component_refs_may_alias_p instead]?
Err, yes ;) I named it after the RTL variant in alias.c.
> Yes, it's a blatant type-punning case but all the structure types are given
> the same alias set (struct p__rec, type of r, type of F) and 'd' is not
> addressable so all the memory accesses are done with the same alias set.
>
> The root of the problem is that same_type_for_tbaa never returns true since
> the types don't have the same TYPE_CANONICAL (rightfully so, they are not
> equivalent) so we fall back to the final return of nonaliasing_c_r_p.
>
> Shouldn't this final return be 'true' instead of 'false', like the final
> return in indirect_ref_may_alias_decl_p, so that the ultimate fallback is the
> comparison of alias sets like it used to be?
I changed this default to false somewhen in the past. There was a
big fat comment there on the alias-improvements branch (where I
wondered if returning false would be a safe thing to do).
I didn't find (or could construct) a single C or C++ testcase that
wasn't fine with the new default, so I switched it (IIRC the default
is disambiguating the most cases).
I'm fine with switching it back though, this time with a comment
explaining why it is not safe (instead of just speculating) and
a testcase (I guess you now indeed have one). Care to prepare
a patch?
Thanks,
Richard.
next prev parent reply other threads:[~2009-10-23 11:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-23 13:43 Eric Botcazou
2009-10-23 14:04 ` Richard Guenther [this message]
2009-10-23 16:20 ` Eric Botcazou
2009-10-23 19:12 ` Eric Botcazou
2009-10-23 23:00 ` Richard Guenther
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=alpine.LNX.2.00.0910231346330.4520@zhemvz.fhfr.qr \
--to=rguenther@suse.de \
--cc=ebotcazou@adacore.com \
--cc=gcc@gcc.gnu.org \
/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).