RFR: 8276151: AArch64: Incorrect result for double to int vector conversion

Ningsheng Jian njian at openjdk.java.net
Thu Nov 4 07:26:40 UTC 2021


Current NEON vector double to integer conversion generates code to convert double to long first and then narrow to integer, which does not follow Java language spec [1], and will get incorrect results for double values larger than Integer.MAX_VALUE or less than Integer.MIN_VALUE. For those too large/small values, result should be the largest/smallest representable value of type int, but converting to long and then narrowing to int will get different results.

There's no direct double to int vector conversion NEON instruction, so we simply do it with scalar conversion.

Also update compiler/vectorapi test cases to cover some corner cases.

[1] https://docs.oracle.com/javase/specs/jls/se17/html/jls-5.html#jls-5.1.3

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

Commit messages:
 - 8276151: AArch64: Incorrect result for double to int vector conversion

Changes: https://git.openjdk.java.net/jdk/pull/6247/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=6247&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8276151
  Stats: 169 lines in 4 files changed: 139 ins; 1 del; 29 mod
  Patch: https://git.openjdk.java.net/jdk/pull/6247.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/6247/head:pull/6247

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


More information about the hotspot-compiler-dev mailing list