RFR: 8283307: Vectorize unsigned shift right on signed subword types

Quan Anh Mai duke at openjdk.java.net
Wed Apr 20 03:07:25 UTC 2022


On Wed, 20 Apr 2022 01:28:04 GMT, Fei Gao <fgao at openjdk.org> wrote:

>> Please also update the comments in the following tests.
>> 
>> compiler/vectorization/runner/ArrayShiftOpTest.java
>> compiler/vectorization/runner/BasicByteOpTest.java
>> compiler/vectorization/runner/BasicShortOpTest.java
>> 
>> 
>> E.g., remove comments like this
>> 
>>     @Test
>>     // Note that unsigned shift right on subword signed integer types can't
>>     // be vectorized since the sign extension bits would be lost.
>>     public short[] vectorUnsignedShiftRight() {
>>         short[] res = new short[SIZE];
>>         for (int i = 0; i < SIZE; i++) {
>>             res[i] = (short) (shorts2[i] >>> 3);
>>         }
>>         return res;
>>     }
>
>> Please also update the comments in the following tests.
> 
> Done. Thanks for your review. @DamonFool

@fg1417 Thanks a lot for your kind explanation, it makes sense now. Do you think it is worth it to generalise to the remaining cases, that is

    0 < c < esize:
    (type)((int)a >>> c) -> a >> c

    esize <= c <= 32 - esize:
    (type)((int)a >>> c) -> a >> (esize - 1)

    32 - esize < c < 32:
    (type)((int)a >>> c) -> (a >> (esize - 1)) >>> (c - (32 - esize))

Here `>>` and `>>>` are true unsigned shifts on the operand types, not exactly the Java scalar operations which actually work on promoted types.

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

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


More information about the hotspot-compiler-dev mailing list