RFR: 6506405: Math.abs(float) is slow

Brian Burkhalter bpb at openjdk.java.net
Wed Jul 7 23:56:48 UTC 2021


On Wed, 7 Jul 2021 20:28:37 GMT, Brian Burkhalter <bpb at openjdk.org> wrote:

> Please consider this change to make the `float` and `double` versions of `java.lang.Math.abs()` branch-free.

On Jul 7, 2021, at 3:44 PM, Rémi Forax ***@***.******@***.***>> wrote:


Your patch change the semantics, actually
Math.abs(Integer.MIN_VALUE) == Integer.MIN_VALUE
with your patch
Math.abs(Integer.MIN_VALUE) == Integer.MAX_VALUE

Does it? The overriding of int arguments shouldn't be affected.

You are right, it does not change abs(int) so it should be Ok.

I checked it earlier and it is OK.

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

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


More information about the core-libs-dev mailing list