[vectorIntrinsics] RFR: 8283598: [vectorapi] Add new vector operation for compress bits

Xiaohong Gong xgong at openjdk.java.net
Thu Mar 24 08:57:05 UTC 2022


On Thu, 24 Mar 2022 08:51:28 GMT, Quan Anh Mai <duke at openjdk.java.net> wrote:

>> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java line 470:
>> 
>>> 468:             a = (byte) (a ^ temp | (temp >> (1 << i))); // Compress a
>>> 469:             count_mask = (byte) (count_mask & ~prefix_mask); // adjust count_mask by identifying bits that have 0 to the right
>>> 470:         }
>> 
>> Hi @smita-kamath , can we simply count the bits number and then do a left shift on the result, e.g:
>> 
>> 1) b =  a & bitmask
>> 2) b = popcount(b)
>> 3) result = (0x1 << b) - 1
>> 
>> Please correct me if I misunderstood something. Thanks so much!
>
> @XiaohongGong  The compression is based on the bits of `bitmask`, not on the bits of `b`, so `bitcompress(0b1001, 0b1100) = 0b10`, `bitcompress(0b0101, 0b1011) = 0b001` (The number of bits in the result I write to be equal to the number of set bits in the mask for easier visualisation).

Oh, I see, thanks for the explanation!

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

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


More information about the panama-dev mailing list