[vectorIntrinsics] RFR: 8265482: [vector] loading/storing byte vector from/to boolean[]

Paul Sandoz psandoz at openjdk.java.net
Tue Apr 27 17:40:42 UTC 2021


On Tue, 27 Apr 2021 17:19:06 GMT, Vladimir Ivanov <vlivanov at openjdk.org> wrote:

> > A byte value is converted to a boolean value by way of the expression (b & 1) != 0 ? true : false, where b is the byte value.
> 
> I'm curious what's the motivation for relying on `(b & 1) != 0` instead of `b != 0`?

I was motivated by what i understood to be the HotSpot's internal representation, so we can do `ByteVector normalized = this.and((byte) 1);`, then store the contents of `normalized` vector directly to memory location of the `boolean[]` array.

Alternatively we could perform a non-zero test to obtain a mask then store the mask, but mask stores to `boolean[]` are not currently intrinsic. Potential to adjust the specification later maybe?

-------------

PR: https://git.openjdk.java.net/panama-vector/pull/71


More information about the panama-dev mailing list