Does HotSpot perform strength reduction on array indexing in a loop?

Tom Rodriguez tom.rodriguez at oracle.com
Tue Dec 7 08:36:50 PST 2010


On Dec 7, 2010, at 4:50 AM, Johan Tibell wrote:

> Hi,
> 
> Does HotSpot perform strength reduction on array indexing in a loop?
> In other words, does it optimize array indexing (i.e. base + offset *
> elem size) to pointer arithmetic (curr_ptr + elem_size)? If it does,
> how does it do so in presence of GC, which could invalidate the
> pointer?

The server compiler doesn't do explicit loop strength reduction though it can get a bit of it as a result of other transformations loop invariant code motion.  I've played a bit with doing it more explicitly but had some difficulty getting benefit from it.  The resulting pointers are handled by the notion of derived pointers.  These are interior pointers that are tracked along with their base pointers.  At the beginning of GC the offset from the base of the derived pointer is saved and the pointer is converted to the base and after GC the offset is added back in.  That part all happens automatically.  Searching for DerivedPointer will lead you to the relevant code.

tom

> 
> Cheers,
> Johan



More information about the hotspot-dev mailing list