[vectorIntrinsics] RFR: 8283598: [vectorapi] Add new vector operation for compress bits
Paul Sandoz
psandoz at openjdk.java.net
Mon Mar 28 21:14:16 UTC 2022
On Mon, 28 Mar 2022 03:45:26 GMT, Eric Liu <eliu at openjdk.org> wrote:
>> Hi,
>>
>> I've added support for new vector operations for compressing bits of integral vector types(Byte/Short/Integer/Long).
>> The implementation is based on Compress or Generalized Extract mentioned in Hackers Delight by Henry S. Warren, Jr.
>> The implementation does the following: given a mask and the number to be compressed, the bits of the number corresponding to the set mask bit are selected and compressed.
>>
>> Currently, this PR addresses only Java changes for compress bits operation. I've also updated the test framework.
>> Do review and share feedback.
>
> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java line 451:
>
>> 449: * Henry S. Warren, Jr's Hackers Delight, Addison Wesley, 2002.
>> 450: */
>> 451: static byte compressBits(byte a, byte bitmask) {
>
> According to the 4th incubation(https://bugs.openjdk.java.net/browse/JDK-8280173), the `compress bit` should be similar to `vector mask compress`(CompressM). As per my understanding, the second argument `bitmask` should be an all true mask here. If so, it also can be removed.
I think i mistook the intended implementation when writing the JEP.
Since there is no scalar equivalent the operation is currently under specified, and in this case I think the expand operation also makes sense so `compress(expand(x, m), m) = x`
-------------
PR: https://git.openjdk.java.net/panama-vector/pull/184
More information about the panama-dev
mailing list