[vectorIntrinsics] RFR: 8281562:[vectorapi] Add support for popcount operation
Paul Sandoz
psandoz at openjdk.java.net
Wed Feb 9 23:29:26 UTC 2022
On Wed, 9 Feb 2022 22:41:36 GMT, Smita Kamath <svkamath at openjdk.org> wrote:
> 8281562:[vectorapi] Add support for popcount operation
src/hotspot/share/prims/vectorSupport.cpp line 482:
> 480: break;
> 481: }
> 482: case VECTOR_OP_POPCNT: {
Can the fall through ever occur? since the operation is only supported for `int` and `long`.
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java line 449:
> 447: /*package-private*/
> 448: @ForceInline
> 449: static int popcount(int a) {
This method is not needed.
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java line 1806:
> 1804: @ForceInline
> 1805: public final
> 1806: IntVector popcnt() {
I recommend not adding such a specific lanewise method for now, and let users use the operation directly.
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java line 449:
> 447: /*package-private*/
> 448: @ForceInline
> 449: static int popcount(long a) {
Method is unnecessary.
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java line 454:
> 452: public static final Unary NEG = unary("NEG", "-a", VectorSupport.VECTOR_OP_NEG, VO_ALL|VO_SPECIAL);
> 453: /** Produce {@code bitCount(a)} */
> 454: public static final Unary POPCNT = unary("POPCNT", "popcnt", VectorSupport.VECTOR_OP_POPCNT, VO_NOFP);
Suggest we rename to BIT_COUNT, so its the same as the method on `Integer` and `Long`. LIkewise for the internal opcode VECTOR_OP_POPCNT -> VECTOR_OP_BIT_COUNT.
test/jdk/jdk/incubator/vector/PopcountUnitTest.java line 39:
> 37: import java.util.stream.IntStream;
> 38:
> 39: public class PopcountUnitTest {
You should replace this test by adding a bitcount test to test framework.
-------------
PR: https://git.openjdk.java.net/panama-vector/pull/173
More information about the panama-dev
mailing list