RFR: 8333721: C2: vectorization causes incorrect execution with unsafe and negative scale

Roland Westrelin roland at openjdk.org
Thu Jun 6 13:31:10 UTC 2024


This was initially a regresion from 8324517 (C2: crash in compiled
code because of dependency on removed range check CastIIs): 8332677
(jck test api/java_math/BigInteger/Bitwise.html fails (c2) on
aarch64). A simplified test case for that one is:


private static void test1(byte[] array, int start) {
    for (int i = start; i < array.length; i++) {
        array[array.length - i - 1] = 0x42;
    }
}


That method is vectorized but with 8324517, the resulting compiled
code is incorrect. I don't think that failure can be reproduced
without 8324517 other than by using unsafe which is what the included
test case does (I'll include the test method above in the redo of
8324517).

The bug is that `VPointer::scaled_iv_plus_offset()` computes an
incorrect offset when `n` is a `Sub` node and the scaled iv is on
input 2 of the `Sub` node and input 2 also includes an offset
component. In that case, the offset from input 2 is added to the
`VPointer` instead of being subtracted.

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

Commit messages:
 - whitespace and copyright
 - test & fix

Changes: https://git.openjdk.org/jdk/pull/19577/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19577&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8333721
  Stats: 151 lines in 2 files changed: 149 ins; 0 del; 2 mod
  Patch: https://git.openjdk.org/jdk/pull/19577.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19577/head:pull/19577

PR: https://git.openjdk.org/jdk/pull/19577


More information about the hotspot-compiler-dev mailing list