RFR: 8342103: C2 compiler support for Float16 type and associated scalar operations [v3]
Jatin Bhateja
jbhateja at openjdk.org
Tue Dec 17 11:09:11 UTC 2024
On Tue, 17 Dec 2024 07:22:45 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> src/hotspot/share/opto/convertnode.cpp line 960:
>>
>>> 958: }
>>> 959: return TypeInt::SHORT;
>>> 960: }
>>
>> Do we have tests for these constant folding operations?
>
> We would need all sorts of conversion with Float16 <-> short. With Float16 constant and variable values. And also with short constant and variable values.
Yes, there are multiple test points in newly added test which receive floating-point constant which goes through following IR logic before being constant folded
ConF -> ConvF2HF -> ReinterpretS2HF
>> src/hotspot/share/opto/divnode.cpp line 826:
>>
>>> 824: t2->getf() != 0.0) {
>>> 825: // could be negative zero
>>> 826: return TypeH::make(t1->getf()/t2->getf());
>>
>> Suggestion:
>>
>> return TypeH::make(t1->getf() / t2->getf());
>
> Are we sure that the rounding behaviour of float is the correct behaviour for Float16? I would like to see some examples where rounding matters.
FP16 has 11 bits precision and FP32 has 24 bit precision, thus as per [2P rule ](https://dl.acm.org/doi/pdf/10.1145/221332.221334) the operation is innocuous to double rounding effects. In addition, fall back implementation of Float16.divide also takes the same route of performing the operation at FP32 granularity.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22754#discussion_r1888331298
PR Review Comment: https://git.openjdk.org/jdk/pull/22754#discussion_r1888330385
More information about the hotspot-compiler-dev
mailing list