RFR: 8284932: [Vector API] Incorrect implementation of LSHR operator for negative byte/short elements

Jie Fu jiefu at openjdk.java.net
Wed Apr 27 09:16:34 UTC 2022


On Tue, 26 Apr 2022 17:31:40 GMT, Jatin Bhateja <jbhateja at openjdk.org> wrote:

> > > According to the Vector API doc, the LSHR operator computes a>>>(n&(ESIZE*8-1))
> 
> Documentation is correct if viewed strictly in context of subword vector lane, JVM internally promotes/sign extends subword type scalar variables into int type, but vectors are loaded from continuous memory holding subwords, it will not be correct for developer to imagine that individual subword type lanes will be upcasted into int lanes before being operated upon.
> 
> Thus both java implementation and compiler handling looks correct.

Thanks @jatin-bhateja for taking a look at this.
After the discussion, I think it's fine to keep the current implementation of LSHR.
So we're now fixing the misleading doc here: https://github.com/openjdk/jdk/pull/8291 .

And I think it would be better to add one more operator for `>>>`.
Thanks.

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

PR: https://git.openjdk.java.net/jdk/pull/8276


More information about the core-libs-dev mailing list