RFR: 8338023: Support two vector selectFrom API [v13]
Sandhya Viswanathan
sviswanathan at openjdk.org
Mon Sep 30 22:42:42 UTC 2024
On Mon, 30 Sep 2024 21:28:22 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
>> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java line 551:
>>
>>> 549: return ((ByteVector)src1).vectorFactory(res);
>>> 550: }
>>> 551:
>>
>> This could instead be:
>> src1.rearrange(this.lanewise(VectorOperators.AND, 2 * VLENGTH - 1).toShuffle(), src2);
>> Or even simplified to:
>> src1.rearrange(this.toShuffle(), src2);
>
> I think you have to do the masking before conversion - `vec.lanewise(VectorOperators.AND, 2 * VLENGTH - 1).toShuffle()` is not the same as `vec.toShuffle()` for all inputs.
>
>
> jshell> IntVector indexes = IntVector.fromArray(IntVector.SPECIES_256, new int[] {0, 1, 8, 9, 16, 17, 24, 25}, 0);
> indexes ==> [0, 1, 8, 9, 16, 17, 24, 25]
>
> jshell> indexes.lanewise(VectorOperators.AND, indexes.length() * 2 - 1)
> $19 ==> [0, 1, 8, 9, 0, 1, 8, 9]
>
> jshell> indexes.lanewise(VectorOperators.AND, indexes.length() * 2 - 1).toShuffle()
> $20 ==> Shuffle[0, 1, -8, -7, 0, 1, -8, -7]
>
> jshell> indexes.toShuffle()
> $21 ==> Shuffle[0, 1, -8, -7, -8, -7, -8, -7]
Thanks for the example. Yes, you have a point there. So we would need to do:
src1.rearrange(this.lanewise(VectorOperators.AND, 2 * VLENGTH - 1).toShuffle(), src2);
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/20508#discussion_r1781859166
More information about the core-libs-dev
mailing list