On Wed, 2011-07-20 at 11:03 +0200, Richard Guenther wrote:

> I wonder if the code below triggered at all as since we expand from
> SSA we no longer see the larger trees in-place but you have to
> look them up via SSA defs using get_gimple_for_ssa_name (or the
> helper get_def_for_expr).  So I expect that the check for a MULT_EXPR
> offset only will trigger if the memory reference was still in the
> form of a variable ARRAY_REF (then get_inner_reference will produce
> an offset of the form i * sizeof (element)).  I think what we want
> to catch here is also the case of *(ptr + i) which will not show
> up as ARRAY_REF but as MEM[ptr + 0] where ptr is an SSA name
> with a defining statement doing ptr' + i * sizeof (element).
> 
> Richard.

Confirmed.  The compiler is pretty smart about reconstructing ARRAY_REFs
out of *(p + i) if p is known to point to an array, but if p is a scalar
pointer with unknown target the code doesn't kick in.  I'll cobble up a
version that tests for both patterns and get some new numbers.

Thanks,
Bill


Reply via email to