RFR(M): 8212043: Add floating-point Math.min/max intrinsics

Pengfei Li (Arm Technology China) Pengfei.Li at arm.com
Fri Oct 19 02:27:12 UTC 2018


Hi,

I would like to enable intrinsics of floating-point Math.min/max methods on AArch64. Could anyone help review this change?
Webrev: http://cr.openjdk.java.net/~pli/rfr/8212043/webrev.00/
JBS:  https://bugs.openjdk.java.net/browse/JDK-8212043

Below is the description of Math.max(double,double) in Java API doc. Behaviors of the other 3 methods are similar.
"Returns the greater of two double values. That is, the result is the argument closer to positive infinity. If the arguments have the same value, the result is that same value. If either value is NaN, then the result is NaN. Unlike the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero. If one argument is positive zero and the other negative zero, the result is positive zero." [1]

In AArch64 floating-point instruction set, the fmax instruction[2] has exactly the same behavior to the API description above. So these min/max calculations can be done in one single instruction.

I also added a jtreg case[3] in this change to test these special arguments, including +0.0, -0.0, +inf, -inf and NaN. I ran the full jtreg test and no new issues were found.

As I'm not familiar with other ISAs, intrinsics are enabled only on AArch64 in this change. I hope someone else can enable them on other platforms, if possible.

[1] https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/lang/Math.html#max(double,double)
[2] https://developer.arm.com/docs/dui0801/latest/a64-floating-point-instructions/fmax-scalar
[3] http://cr.openjdk.java.net/~pli/rfr/8212043/webrev.00/test/hotspot/jtreg/compiler/intrinsics/math/TestFpMinMaxIntrinsics.java.html

--
Thanks,
Pengfei



More information about the hotspot-compiler-dev mailing list