RFR(S): 8182475: C2: allow vectorization of HeapByteBuffer.putInt loops

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RFR(S): 8182475: C2: allow vectorization of HeapByteBuffer.putInt loops

Roland Westrelin-3

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.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RFR(S): 8182475: C2: allow vectorization of HeapByteBuffer.putInt loops

Vladimir Kozlov
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.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RFR(S): 8182475: C2: allow vectorization of HeapByteBuffer.putInt loops

Roland Westrelin-3

> Very good. Nice finding!

Thanks for the review, Vladimir. Can anyone sponsor this change?

Roland.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RFR(S): 8182475: C2: allow vectorization of HeapByteBuffer.putInt loops

Vladimir Kozlov
I submitted RBT testing.

Vladimir

On 7/26/17 6:52 AM, Roland Westrelin wrote:
>
>> Very good. Nice finding!
>
> Thanks for the review, Vladimir. Can anyone sponsor this change?
>
> Roland.
>
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RFR(S): 8182475: C2: allow vectorization of HeapByteBuffer.putInt loops

Roland Westrelin-3

> I submitted RBT testing.

Thanks!

Roland.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RFR(S): 8182475: C2: allow vectorization of HeapByteBuffer.putInt loops

Roland Westrelin-3

Thanks for pushing this, Vladimir.

Roland.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RFR(S): 8182475: C2: allow vectorization of HeapByteBuffer.putInt loops

Andrew Haley
On 28/07/17 15:41, Roland Westrelin wrote:
>
> Thanks for pushing this, Vladimir.

I don't normally say this, but:

  +1.  me too!

--
Andrew Haley
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
Loading...