RFR: 8305324: C2: Wrong execution of vectorizing Interger.reverseBytes [v4]

Vladimir Kozlov kvn at openjdk.org
Tue Apr 11 16:08:44 UTC 2023


On Tue, 11 Apr 2023 11:48:26 GMT, Daohan Qu <duke at openjdk.org> wrote:

>> This patch should fix [JDK-8305324](https://bugs.openjdk.org/browse/JDK-8305324).
>> 
>> `SuperWord::compute_vector_element_type()` implemented in `jdk/src/hotspot/share/opto/superword.cpp` propagates backward a narrower integer type when the upper bits of the value are not needed. However, `Integer.reverseBytes()` depends on higher-order bits of an integer and should be prevented from being narrowed and vectorized. Instead, it needs to be treated like `Math.abs()` (which is represented by `Op_AbsI` in the following code).
>> 
>> https://github.com/openjdk/jdk/blob/0243da2e4adc1b7ab6fcd5b10778532101158dce/src/hotspot/share/opto/superword.cpp#L3935-L3945
>> 
>> I have tested this patch for tier 1-3 on x86-64.
>
> Daohan Qu has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update full name

src/hotspot/share/opto/vectornode.cpp line 440:

> 438: // of its higher order bits/bytes
> 439: bool VectorNode::requires_higher_order_bits_of_integer(int opc) {
> 440:   if (is_shift_opcode(opc) && opc != Op_LShiftI) {

Checking Op_LShiftI here will change behavior for `Short s = LShiftI(LoadB)` case and similar. May be it is okay and previous code worked because we did not vectorize due to different sizes of destination and Load.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/13406#discussion_r1163041647


More information about the hotspot-compiler-dev mailing list