This is the mail archive of the
mailing list for the GCC project.
Re: Aliasing: look through pointer's def stmt
- From: Richard Biener <richard dot guenther at gmail dot com>
- To: Marc Glisse <marc dot glisse at inria dot fr>
- Cc: Jeff Law <law at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 29 Oct 2013 10:22:42 +0100
- Subject: Re: Aliasing: look through pointer's def stmt
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot DEB dot 2 dot 02 dot 1310250707430 dot 14734 at stedding dot saclay dot inria dot fr> <526A0269 dot 8030407 at redhat dot com> <alpine dot DEB dot 2 dot 10 dot 1310250809590 dot 4165 at laptop-mg dot saclay dot inria dot fr> <CAFiYyc27=sN1itn+N09rpmm8tWGt-Khu7oASLd0ODsdZh=ofzw at mail dot gmail dot com> <CAFiYyc2EtayY0tiW1pz4t-zf0uVC24UcF5s7yaUrY3f7_jxoVg at mail dot gmail dot com> <alpine dot DEB dot 2 dot 10 dot 1310251123350 dot 8620 at laptop-mg dot saclay dot inria dot fr> <CAFiYyc2WmH4WNZ7h8-8iC_6mSO50PdLNLxNzQOYZrYEvn1oQkQ at mail dot gmail dot com> <alpine dot DEB dot 2 dot 02 dot 1310251852480 dot 9786 at stedding dot saclay dot inria dot fr> <alpine dot DEB dot 2 dot 10 dot 1310261838280 dot 15626 at laptop-mg dot saclay dot inria dot fr>
On Sat, Oct 26, 2013 at 7:07 PM, Marc Glisse <firstname.lastname@example.org> wrote:
> On Fri, 25 Oct 2013, Marc Glisse wrote:
>> On Fri, 25 Oct 2013, Richard Biener wrote:
>>> you can followup with handling POINTER_PLUS_EXPR if you like.
>> Like this? (bootstrap+testsuite on x86_64-unknown-linux-gnu)
>> 2013-10-26 Marc Glisse <email@example.com>
>> * tree-ssa-alias.c (ao_ref_init_from_ptr_and_size): Look for a
>> POINTER_PLUS_EXPR in the defining statement.
> This has some issues with the type of the offsets. First, they might
> overflow in some extreme cases (that could probably already happen without
> the patch). But mostly, negative offsets are not supported. There is a
> comment to that effect before ao_ref_init_from_ptr_and_size, and
> ranges_overlap_p takes the offsets as unsigned HOST_WIDE_INT. Currently it
> does indeed seem hard to produce a negative offset there, but handling
> POINTER_PLUS_EXPR (definitely a good thing) would obviously change that.
For the POINTER_PLUS_EXPR offset argument you should use
int_cst_value () to access it (it will unconditionally sign-extend)
and use host_integerp (..., 0). That leaves the overflow possibility
in place (and you should multiply by BITS_PER_UNIT) which we
ignore in enough other places similar to this to ignore ...
(side-note: for quite some time on my TODO is to make the
gimple alias-machinery use byte-offsets instead of bit-offsets
which wouldn't cause regressions if we finally lowered bitfield
accesses ...). A way to not ignore it is to do
off = double_int_from_tree (ptr-plus-offset);
off = double_int_sext (off, TYPE_PRECISION (...))
off = double_int_mul (off, BITS_PER_UNIT);
if (off.fits_shwi ())
> Marc Glisse