On Fri, 6 Sep 2024 18:08:09 GMT, Jatin Bhateja <jbhat...@openjdk.org> wrote:

>> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Vector.java line 
>> 2770:
>> 
>>> 2768: 
>>> 2769:     /**
>>> 2770:      * Rearranges the lane elements of two vectors, selecting lanes
>> 
>> I have a bit of a name concern here. Why are we calling it "select" and not 
>> "rearrange"? Because for a single "from" vector we also call it "rearrange", 
>> right? Is "select" not often synonymous to "blend", which works also with 
>> two "from" vectors, but with a mask and not indexing for 
>> "selection/rearranging"?
>
> We already have another flavor of 
> [selectFrom](https://docs.oracle.com/en/java/javase/22/docs/api/jdk.incubator.vector/jdk/incubator/vector/Vector.html#selectFrom(jdk.incubator.vector.Vector))
>  which permutes single vector, new API extents its semantics to two vector 
> selection, so we kept the nomenclature consistent.

Select operates only on vectors where the `this` vector represents the indexes 
to *select* elements from the other vectors. Rearrange operates on vectors and 
a shuffle argument that *rearranges* elements from the other vectors. The 
former behavior can be specified in terms of the latter behavior, and ideally 
the equivalent expressions should result in ~same generated sequence of 
instructions. However, we are not there yet and need to further optimize 
shuffles to make that happen. But, we can optimize `selectFrom` with the 
dependent change to wrap indexes instead of throwing when out of bounds.

(Separately there is an annoying issue with select, that we should not address 
in this PR. Using a Float/Double Vector for indexes is awkward.)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/20508#discussion_r1759182233

Reply via email to