openj9 icon indicating copy to clipboard operation
openj9 copied to clipboard

WIP: Z: Enable inlining of floating point max/min calls

Open sarwat12 opened this issue 1 year ago • 2 comments

This draft PR adds the following as recognized methods:

java_lang_Math_max_F
java_lang_Math_min_F
java_lang_Math_max_D
java_lang_Math_min_D

, and adds a SupportsInline flag to the code generator for enabling the inlining of floating point min and max on Z. This flag is set in Z code generator initialization if the TR_disableInlineMathMax/MathMin environment variable is not set. If the flag is set, Math.max/min call nodes are transformed to a functionally equivalent tree that uses fmax/fmin/dmax/dmin.

sarwat12 avatar Feb 15 '24 18:02 sarwat12

Math.max/min call nodes are transformed to a functionally equivalent tree that uses fmax/fmin/dmax/dmin

One oddity about java.lang.Math.{max|min}({double|float}) is in the treatment of negative zero:

Unlike the numerical comparison operators, this method considers negative zero to be strictly smaller than positive zero.

Do the OMR fmax/fmin/dmax/dmin meet that requirement?

hzongaro avatar Feb 16 '24 15:02 hzongaro

Thanks @hzongaro for pointing this out. OMR evaluators would not meet the requirement. @sarwat12 Please reevaluate/update the generated instructions and make sure that it adheres to the Java SPEC

r30shah avatar Feb 16 '24 16:02 r30shah