This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Aliasing: look through pointer's def stmt

On Sat, Oct 26, 2013 at 7:07 PM, Marc Glisse <> 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  <>
>> gcc/
>>         * 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

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]