RFR(S): 8182475: C2: allow vectorization of HeapByteBuffer.putInt loops
Vladimir Kozlov
vladimir.kozlov at oracle.com
Mon Jun 19 16:44:22 UTC 2017
Very good. Nice finding!
Thanks,
Vladimir
On 6/19/17 9:12 AM, Roland Westrelin wrote:
>
> http://cr.openjdk.java.net/~roland/8182475/webrev.00/
>
> With the following loop (straight out of Andrew's ByteBufferTest that we
> discussed before):
>
> static final ByteBuffer buf = ByteBuffer.allocate(SIZE * 4);
>
> for (int i = 0; i < SIZE; i++) {
> buf.putInt(i<<2, n);
> }
> }
>
> vectorization doesn't trigger.
>
> putInt is implemented as:
>
> unsafe.putIntUnaligned(hb, address + checkIndex(i, 4), x, bigEndian);
>
> The address of the StoreI nodes have the following shape:
>
> (AddP (AddP hb (LoadL address)) (ConvI2L (LshiftI iv_phi 2)))
>
> The LoadL is loop invariant. SWPointer::SWPointer() fails for them
> because SWPointer::offset_plus_k() bails out for a long invariant. The
> long invariant is only used in SuperWord::align_initial_loop_index() in
> a computation for which we only keep the least significant bits. So I
> think it's safe to use the long loop invariant by casting it to int in
> SuperWord::align_initial_loop_index().
>
> Roland.
>
More information about the hotspot-compiler-dev
mailing list