RFR: 8266028: C2 computes -0.0 for Math.pow(-0.0, 0.5)
Jie Fu
jiefu at openjdk.java.net
Tue Apr 27 08:34:43 UTC 2021
Hi all,
C2 computes -0.0 for Math.pow(-0.0, 0.5) which should be 0.0 according to the API specs.
This bug was found while I was implementing the same optimization for x86_32 (JDK-8265940).
The reason is that CmpDNode [1] doesn't distinguish -0.0 from 0.0.
Math.pow(-0.0, 0.5) was replaced with Math.sqrt(-0.0) incorrectly since CmpDNode says -0.0 < 0.0 if false.
The fix excludes C2's optimization for x=0.0/-0.0.
And the jtreg test has been improved to make sure the corner cases are covered by the compilers.
Thanks.
Best regards,
Jie
[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/library_call.cpp#L1656
-------------
Commit messages:
- 8266028: C2 computes -0.0 for Math.pow(-0.0, 0.5)
Changes: https://git.openjdk.java.net/jdk/pull/3712/files
Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3712&range=00
Issue: https://bugs.openjdk.java.net/browse/JDK-8266028
Stats: 21 lines in 2 files changed: 9 ins; 11 del; 1 mod
Patch: https://git.openjdk.java.net/jdk/pull/3712.diff
Fetch: git fetch https://git.openjdk.java.net/jdk pull/3712/head:pull/3712
PR: https://git.openjdk.java.net/jdk/pull/3712
More information about the hotspot-compiler-dev
mailing list