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

Xiaohong Gong xgong at openjdk.java.net
Tue Mar 29 09:45:04 UTC 2022


On Thu, 24 Mar 2022 06:31:31 GMT, Smita Kamath <svkamath 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/X-Vector.java.template line 478:

> 476:         int iters = 6;
> 477: #end[int]
> 478: #end[intOrLong]

why not simply with:

#if[int]
        int iters = 5;
#end[int]
#if[long]
        int iters = 6;
#end[long]

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template line 500:

> 498: #end[intOrLong]
> 499:             move_mask = ($type$) (prefix_mask & bitmask); // Bits to move
> 500:             bitmask = ($type$)(bitmask ^ move_mask | (move_mask >> (1 << i))); // Compress bitmask

style: space between `($type$)(bitmask ^ move_mask | ...)`

test/jdk/jdk/incubator/vector/templates/Unit-header.template line 1507:

> 1505:         a = ($type$) (a & b);
> 1506:         $type$ count_mask = ($type$) (~b << 1);
> 1507:         $type$ mp, mv, t;

These are not used?

test/jdk/jdk/incubator/vector/templates/Unit-header.template line 1536:

> 1534: #end[intOrLong]
> 1535:             move_mask = ($type$) (prefix_mask & b);
> 1536:             b = ($type$)(b ^ move_mask | (move_mask >> (1 << i)));

style: add one space between `($type$)(b ^ move_mask ...)`

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

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


More information about the panama-dev mailing list