RFR: 8284932: [Vector API] Incorrect implementation of LSHR operator for negative byte/short elements
Jie Fu
jiefu at openjdk.java.net
Tue Apr 19 23:18:27 UTC 2022
On Tue, 19 Apr 2022 17:40:07 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:
> Not yet talked with John, but i investigated further. The implementation of the `LSHR` operation is behaving as intended, but is under specified with regards to `byte` and `short` as you noted in #8291.
>
> This is a subtle area, but i am wondering if the user really means to use arithmetic shift in this case? Since is not the following true for all values of `e` and `c`, where `e` is a `byte` and `c` is the right shift count ranging from 0 to 7:
>
> ```
> (byte) (e >>> c) == (byte) (e >> c)
> ```
>
> ?
>
> Then the user can use `VectorOperators.ASHR`.
Yes, in theory, the user can use `ASHR`.
But people have to be very careful about when to use `AHSR` and when to use `LSHR`, which is really inconvenient and easy to make a mistake.
And not all the people are smart enough to know this skill for bytes/shorts.
So to make it to be programmed more easily and also reduce the possibility to make mistakes, a new operator for scalar `>>>` would be helpful when vectorizing with Vector API.
Thanks.
-------------
PR: https://git.openjdk.java.net/jdk/pull/8276
More information about the core-libs-dev
mailing list