User account creation filtered due to spam.
Given 2 pointers p and q, if the alias information says that p and q
cannot alias, then comparisons like p == q and p != q can be optimized away.
There are quite a few examples in:
Is this fixed?
Subject: Re: [tree-ssa] make "fold" use alias information to optimize pointer comparisons
"steven at gcc dot gnu dot org" <firstname.lastname@example.org> writes:
> ------- Comment #3 from steven at gcc dot gnu dot org 2006-12-10 18:18 -------
> Is this fixed?
No, it's not.
Richi, this may be easy to fix on the AIB...
Easy but dangerous ;)
While looking at some unrelated issue, I noticed the following:
_41 = operator new (28);
if (_41 != &_S_empty_rep_storage)
which happens with a simple use of std::string (with some extra inlining). __builtin_malloc(42)==&var is not optimized either, so it isn't (only) an issue with operator new.
If the general case is too dangerous, maybe there is at least some subset that could safely be optimized?
On Thu, 14 Aug 2014, glisse at gcc dot gnu.org wrote:
> --- Comment #7 from Marc Glisse <glisse at gcc dot gnu.org> ---
> While looking at some unrelated issue, I noticed the following:
> _41 = operator new (28);
> if (_41 != &_S_empty_rep_storage)
> which happens with a simple use of std::string (with some extra inlining).
> __builtin_malloc(42)==&var is not optimized either, so it isn't (only) an issue
> with operator new.
> If the general case is too dangerous, maybe there is at least some subset that
> could safely be optimized?
Well, not sure if really "dangerous", but yes, doing pointer against
address-of-decl disambiguation should be easily possible.
I'll try to hack sth together later today.
Created attachment 33336 [details]
Like this - does it help the particular case?
Note that one issue is that points-to doesn't track NULL-ness reliably
(like may-point to zero if it may point to a weak decl), and we drop
maybe-NULL-ness because we don't use it. Likewise we don't keep track
of pointers to CONST_DECLs or LABEL_DECLs or FUNCTION_DECLs (we simply
drop them on the floor rather than treating them as "anything").
The patch doesn't bootstrap which means it probably reveals bugs in
points-to. This is what I meant with "dangerous" ;)
(In reply to Richard Biener from comment #9)
> Created attachment 33336 [details]
> Like this - does it help the particular case?
_S_empty_rep_storage has DECL_WEAK, so it doesn't help here :-(
For GCC 7 we can now do ptr != decl (for certain kinds of decls). I have
patches extending this to the ptr != ptr case but they need work because PTA
needs to handle points-to NULL (aka nothing) and STRING_CST (and LABEL_DECL
and FUNCTION_DECL, etc.) conservatively. Comparing LABEL_DECL against
FUNCTION_DECL will also be interesting, so not sure if we can ever make
this work (maybe glob LABEL_DECLs with their containing FUNCTION_DECLs for
Date: Fri Apr 29 08:36:49 2016
New Revision: 235622
2016-04-29 Richard Biener <email@example.com>
* tree-ssa-alias.h (ptrs_compare_unequal): Declare.
* tree-ssa-alias.c (ptrs_compare_unequal): New function
using PTA to compare pointers.
* match.pd: Add pattern for pointer equality compare simplification
* gcc.dg/uninit-pr65686.c: New testcase.
*** Bug 78412 has been marked as a duplicate of this bug. ***