RFR: 8288933: Improve the implementation of Double/Float.isInfinite

Quan Anh Mai duke at openjdk.org
Wed Jun 22 12:51:21 UTC 2022


Improve the implementation of `Double/Float.isInfinite` to reduce branching. Using `>` comparison with `MAX_VALUE` instead of `==` with `POSITIVE_INFINITY` improves code emission on x86 and produces similar code for arm. This is also the way gcc implements `std::isinf` on x86 and arm (clang uses the pattern `Math.abs(v) == POSITIVE_INFINITY` on arm).

`test/micro/org/openjdk/bench/java/lang/FPComparison.java` has been added in #8525, the results are reshown here:

    Benchmark                      Mode  Cnt     Score     Error    Score     Error   Unit   Ratio
    FPComparison.isInfiniteDouble  avgt    5  1232.800 ±  31.677  621.185 ±  11.935  ns/op    1.98
    FPComparison.isInfiniteFloat   avgt    5  1234.708 ±  70.239  623.566 ±  15.206  ns/op    1.98

Thank you very much.

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

Commit messages:
 - commit

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

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


More information about the core-libs-dev mailing list