adjust generation of component addresses

Richard Henderson rth@redhat.com
Mon Feb 25 12:04:00 GMT 2002


On Mon, Feb 25, 2002 at 07:13:49AM -0500, Richard Kenner wrote:
>     I've built a cross gnat1; hopefully I'll be able to reproduce this.
> 
> Note that the problem exists on all machines, but it's just the 32/64 where
> it always causes bad code.

So you've identified the place within the compiler that the problem
appears?  Care to share?

> If you do the index calculation by subtracting the lower bound from
> the index and then multiplying by the size, you're guaranteed not
> to overflow, but if you multiply the index by the size, you will overflow.

Really I wouldn't have thought my change affected this.  What we
were generating before my change for

	base->array[index]

where array is offset from base by a constant is

	tmp1 = base + array_offset;
	tmp2 = index * array_elt_size;
	tmp3 = tmp1 + tmp2;
	(mem tmp3)

With my change this is supposed to be reordered to

	tmp1 = index * array_elt_size;
	tmp2 = tmp1 + base;
	tmp3 = tmp2 + array_offset;
	(mem tmp3)

I.e. what's inside the multiplication should not have changed at all.
I'd expect arrays with non-zero lower bounds to continue to be reduced
to zero-based indicies before the multiplication.


r~



More information about the Gcc-patches mailing list