On Tue, 17 Dec 2024 07:22:45 GMT, Emanuel Peter <epe...@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

Reply via email to