[lworld+fp16] RFR: 8345053: Add support for FP16 valueOf routines [v2]
Jatin Bhateja
jbhateja at openjdk.org
Mon Feb 3 11:25:03 UTC 2025
On Fri, 24 Jan 2025 13:45:42 GMT, Bhavana Kilambi <bkilambi at openjdk.org> wrote:
>> This patch adds intrinsic support for Float16.valueOf() routines - conversions from int/long/double to half float.
>
> Bhavana Kilambi has updated the pull request incrementally with one additional commit since the last revision:
>
> Add new microbenchmarks for valueOf() routines
src/hotspot/share/opto/convertnode.cpp line 204:
> 202:
> 203: //------------------------------Identity---------------------------------------
> 204: // Half-Float's can be converted to doubles with no loss of bits. Hence
Suggestion:
// Half-Float's can be converted to doubles with no loss of precision. Hence
src/hotspot/share/opto/vectornode.cpp line 1450:
> 1448: case Op_VectorCastD2HF: return new VectorCastD2HFNode(n1, vt);
> 1449: case Op_VectorCastL2HF: return new VectorCastL2HFNode(n1, vt);
> 1450:
We can optimize creating new vector IR once mainline patch gets integrated as I have added an explicit ideal type for HalfFloats, thus existing D2X, I2X and L2X IR can be used and we can perform a type based checks in matcher.
src/java.base/share/classes/java/lang/Float16.java line 391:
> 389:
> 390: @IntrinsicCandidate
> 391: private static short longToFloat16(long value) {
Offlate there have been some concerns around keeping java side changes to a minimum, doing boxing on the compiler side involves additional work, please refer to my changes on mainline
https://github.com/openjdk/jdk/pull/22754/commits/692de9c03fb6344f9602617f0bed75c28c409ed0#diff-1929ace9ae6df116e2fa2a718ed3924d9dae9a2daea454ca9a78177c21477aa3R8641
But, for now, this looks ok, we can fine-tune going forward once we reach a stage of JDK mainline integration.
test/hotspot/jtreg/compiler/c2/irTests/ConvD2HFTransformationTests.java line 61:
> 59: failOn = {IRNode.CONV_D2HF, IRNode.CONV_I2D},
> 60: applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"})
> 61: // Test Ideal transformation of ConvD2HF node : pattern ConvI2D -> ConvD2HF is optimized to ConvI2HF
Fix indentation
test/hotspot/jtreg/compiler/c2/irTests/ConvD2HFTransformationTests.java line 81:
> 79: @IR(failOn = {IRNode.CONV_D2HF, IRNode.CONV_HF2D},
> 80: applyIfCPUFeatureAnd = {"fphp", "true", "asimdhp", "true"})
> 81: // Test Identity transformation of ConvD2HF node : pattern - ConvHF2D -> ConvD2HF is optimized away
Fix indentation
-------------
PR Review Comment: https://git.openjdk.org/valhalla/pull/1332#discussion_r1939069295
PR Review Comment: https://git.openjdk.org/valhalla/pull/1332#discussion_r1939184818
PR Review Comment: https://git.openjdk.org/valhalla/pull/1332#discussion_r1939037593
PR Review Comment: https://git.openjdk.org/valhalla/pull/1332#discussion_r1939211938
PR Review Comment: https://git.openjdk.org/valhalla/pull/1332#discussion_r1939212313
More information about the valhalla-dev
mailing list