JDK-8289552 : Make intrinsic conversions between bit representations of half precision values and floats
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 20
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2022-06-30
  • Updated: 2024-08-09
  • Resolved: 2022-10-11
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 20
20 b19Fixed
Related Reports
Blocks :  
Blocks :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
Make intrinsic on supporting x86 hardware the methods convert between the bit representation of a half precision floating point (float16) value and float. 
Comments
A pull request was submitted for review. Branch: master URL: https://git.openjdk.org/jdk/pull/9781 Date: 2022-08-05 16:36:23 +0000
09-08-2024

Or it could be totally separate change from JDK-8302976.
27-02-2023

[~jbhateja] Please repeat this comment in follow up bug I am working on JDK-8302976
27-02-2023

Excerpt from JVM 19 Specification section 2.8: The Java Virtual Machine does not support IEEE 754 signaling floating-point comparisons, and has no signaling NaN value. Thus an operation over NaN should result into QNaN value. Interpreter implementation of floatToFloat16 does set all the exponent bits but not the MSB of significand, thus leaves a path open for generation of SNaN values. Similar change may be needed in SharedRuntime::f2hf. diff --git a/src/java.base/share/classes/java/lang/Float.java b/src/java.base/share/classes/java/lang/Float.java index b4e212434ae..88c8b1470ca 100644 --- a/src/java.base/share/classes/java/lang/Float.java +++ b/src/java.base/share/classes/java/lang/Float.java @@ -1096,7 +1096,7 @@ public final class Float extends Number if (Float.isNaN(f)) { // Preserve sign and attempt to preserve significand bits return (short)(sign_bit - | 0x7c00 // max exponent + 1 + | 0x7e00 // max exponent + 1 // Preserve high order bit of float NaN in the // binary16 result NaN (tenth bit); OR in remaining // bits into lower 9 bits of binary 16 significand.
25-02-2023

the intrinsic may return different value than the interpreter, is this expected? public class Foo { public static short bar(float f) {return Float.floatToFloat16(f);} public static void main(String[] args) {System.out.println(bar(Float.float16ToFloat((short) 31745)));} } prints 32257 with -XX:-TieredCompilation -Xcomp
26-01-2023

Changeset: 07946aa4 Author: Smita Kamath <svkamath@openjdk.org> Committer: Sandhya Viswanathan <sviswanathan@openjdk.org> Date: 2022-10-11 17:06:19 +0000 URL: https://git.openjdk.org/jdk/commit/07946aa49c97c93bd11675a9b0b90d07c83f2a94
11-10-2022