-
Bug
-
Resolution: Unresolved
-
P3
-
None
-
8u144
-
/opt/ts/bin/java -version
java version "1.8.0_144"
Java(TM) SE Runtime Environment (build 1.8.0_144-b01)
Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)
-
x86
-
linux_ubuntu
The following program demonstrates that the x * x optimization when exp == 2 is still broken for jdk-8 (it is fixed on jdk-9):
public class PowTest {
public static void main(final String[] args) {
double b = 1.0 / 3.0;
double e = 2.0;
double r = Math.pow(b, e);
double n = b * b;
// Find a base where pow(b, 2) != b * b
while (r == n) {
b += 1.0 / 3.0;
n = Math.pow(b, e);
r = b * b;
}
System.out.println("found b=" + b + " n=" + n + " r=" + r);
r = n = Math.pow(b, e);
// Wait until pow gets compiled into x * x
while (r == n) {
n = Math.pow(b, e);
}
System.out.println("bad b=" + b + " n=" + n + " r=" + r);
}
}
Please fix it (it is causing us a lot of pain to have to deal with the same code producing different numeric results on each run). It would be nice at some point to require in the language that intrinsic math functions produce the same exact results when interpreted and compiled.
public class PowTest {
public static void main(final String[] args) {
double b = 1.0 / 3.0;
double e = 2.0;
double r = Math.pow(b, e);
double n = b * b;
// Find a base where pow(b, 2) != b * b
while (r == n) {
b += 1.0 / 3.0;
n = Math.pow(b, e);
r = b * b;
}
System.out.println("found b=" + b + " n=" + n + " r=" + r);
r = n = Math.pow(b, e);
// Wait until pow gets compiled into x * x
while (r == n) {
n = Math.pow(b, e);
}
System.out.println("bad b=" + b + " n=" + n + " r=" + r);
}
}
Please fix it (it is causing us a lot of pain to have to deal with the same code producing different numeric results on each run). It would be nice at some point to require in the language that intrinsic math functions produce the same exact results when interpreted and compiled.
- relates to
-
JDK-8029302 Performance regression in Math.pow intrinsic
- Resolved
-
JDK-8145688 update for x86 pow in the math lib
- Resolved
-
JDK-8063086 Math.pow yields different results upon repeated calls
- Resolved