On Thu, 22 Jan 2026 06:29:26 GMT, Varada M <[email protected]> wrote:

>> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java
>>  line 185:
>> 
>>> 183:         // NOTE:  This assumes that convert0('X')
>>> 184:         // respects REGISTER_ENDIAN order.
>>> 185:         return convert0('X', 
>>> vspecies().withLanes(laneType)).maybeSwapOnConverted(java.nio.ByteOrder.nativeOrder(),
>>>  vspecies());
>> 
>> Would `swapIfNeeded` be a better name?
>> I think we could determine the ByteOrder where it is used. Then, we don't 
>> have to pass it any more.
>
> I agree, looks more clean. I have renamed  and made the suggested changes

Thanks! My idea was to move `java.nio.ByteOrder.nativeOrder()` to 
`subLanesToSwap` where the only usage is AFAICS.

>> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/AbstractVector.java
>>  line 217:
>> 
>>> 215:         int sBytes = srcSpecies.elementSize();
>>> 216:         int tBytes = vspecies().elementSize();
>>> 217:         if (sBytes == tBytes || (sBytes % tBytes) != 0) {
>> 
>> What do we do if it's not divisible? Should we better throw an exception?
>
> I have tried adding the exception but many tests failed!
> what I understood is asVectorRawTemplate is called in many cases which 
> eventually calls swapIfNeeded and exception is thrown for the widening cases. 
> When we reinterpret smaller elements into larger ones we don't need to swap 
> elements so we could opt out.

Ok, a comment would be helpful.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/28425#discussion_r2716289852
PR Review Comment: https://git.openjdk.org/jdk/pull/28425#discussion_r2716283133

Reply via email to