On Mon, 30 Sep 2024 22:39:09 GMT, Sandhya Viswanathan <sviswanat...@openjdk.org> wrote:
>> 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); > This could instead be: src1.rearrange(this.lanewise(VectorOperators.AND, 2 * > VLENGTH - 1).toShuffle(), src2); Or even simplified to: > src1.rearrange(this.toShuffle(), src2); Yes, this may save additional allocation penalty of result array allocation which may slightly improve fall back performance, but logical operation cannot be directly applied over floating point vectors. so, we will need an explicit conversion to integral vector, which is why I opted for current fallback implementation which is in line with rest of the code. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/20508#discussion_r1782480053