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

Claes Redestad redestad at openjdk.org
Fri Sep 9 13:16:44 UTC 2022


On Wed, 22 Jun 2022 12:43:53 GMT, Quan Anh Mai <duke at openjdk.org> wrote:

> 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.

Looks good to me!

(Sorry for the long delay, I've been out for a while and forgot to formally review this.)

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

Marked as reviewed by redestad (Reviewer).

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


More information about the core-libs-dev mailing list