ADDITIONAL SYSTEM INFORMATION :
Ubuntu 18.04 on x86_64
$ java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1)
OpenJDK 64-Bit Server VM (build 11.0.8+10-post-Ubuntu-0ubuntu118.04.1, mixed mode, sharing)
A DESCRIPTION OF THE PROBLEM :
I found Math.fma(float, float, float) method returned different values with or without -XX:-UseFMA VM option for the same inputs.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Save the code as FMAExample.java
2. Run `javac FMAExample.java`
3. Run `java -XX:-UseFMA FMAExample`
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Step 3 prints out 0x1.000002p52
ACTUAL -
Step 3 printed out 0x1.000004p52
---------- BEGIN SOURCE ----------
public class FMAExample {
public static void main(String[] args) {
float a = 0x1.fffffep23f;
float b = 0x1.000004p28f;
float c = 0x1.fep5f;
// The below line prints out different values for +/-UseFMA option.
// -XX:+UseFMA: 0x1.000002p52
// -XX:-UseFMA: 0x1.000004p52
System.out.printf("%a\n", Math.fma(a, b, c));
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
Do not specify `java -XX:-UseFMA FMAExample`