On Mon, 18 Apr 2022 04:25:23 GMT, Quan Anh Mai <d...@openjdk.java.net> wrote:
> > However, just image that someone would like to optimize some code segments > > of bytes/shorts `>>>` > > Then that person can just use signed shift (`VectorOperators.ASHR`), right? > Shifting on masked shift counts means that the shift count cannot be greater > than 8 for bytes and 16 for shorts, which means that `(byte)(src[i] >>> 3)` > is exactly the same as `(byte)(src[i] >> 3)`. Please correct me if I > misunderstood something here. Yes, you're right that's why I said `LSHR` can be replaced with `ASHR`. However, not all the people are clever enough to do this source code level replacement. To be honest, I would never think of that `>>>` can be auto-vectorized by this idea proposed by https://github.com/openjdk/jdk/pull/7979 . > > Your proposed changes make unsigned shifts for subwords behave exactly the > same as signed shifts, which is both redundant (we have 2 operations doing > exactly the same thing) and inadequate (we lack the operation to do the > proper unsigned shifts) `LSHR` following the behavior of scalar `>>>` is very important for Java developers to rewrite the code with vector api. Maybe, we should add one more operator to support what you called `the proper unsigned shifts`, right? But that's another topic which can be done in a separate issue. ------------- PR: https://git.openjdk.java.net/jdk/pull/8276