RFR: 8256973: Intrinsic creation for VectorMask query (lastTrue, firstTrue, trueCount) APIs

Jatin Bhateja jbhateja at openjdk.java.net
Fri May 7 18:15:45 UTC 2021


On Fri, 7 May 2021 16:02:05 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

> These mask operations can be considered a form of reduction.
> 
> Do you think it makes sense to reuse `VectorSupport.reductionCoerced` instead of adding a new intrinsic? (Note that we reuse `VectorSupport.binaryOp` for mask logical binary operations).
> 
> Perhaps that allows for further reuse later if/when we add operations to integral vectors to count bits like we already have with scalars, such as `Integer.bitCount`, `Integer.numberOfLeadingZeros` etc?

Hi @PaulSandoz , that's a nice suggestion, I think instead of reduction which may emit bulky sequence, VectorMask.toLong() + Long.bitCount() could have been used for trueCount. But since toLong may not work for ARM SVE, so in the mean time intrinsifying at the level of API looked reasonable.

> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractMask.java line 147:
> 
>> 145: 
>> 146:     /*package-private*/
>> 147:     static int trueCountHelper(boolean[] bits) {
> 
> Naming-wise i think you can drop `Helper` from such methods.

This is indeed a Helper routine called from the lambda expression.

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

PR: https://git.openjdk.java.net/jdk/pull/3916


More information about the hotspot-compiler-dev mailing list