RFR: 8352635: Improve inferencing of Float16 operations with constant inputs [v5]
Jatin Bhateja
jbhateja at openjdk.org
Wed Jun 4 12:40:00 UTC 2025
On Wed, 4 Jun 2025 06:28:44 GMT, Emanuel Peter <epeter at openjdk.org> wrote:
>> src/hotspot/share/opto/convertnode.cpp line 304:
>>
>>> 302: // expression, this downcast will still preserve significand bits of binary32 NaN.
>>> 303: bool isnan = ((*reinterpret_cast<jint*>(&con) & 0x7F800000) == 0x7F800000) &&
>>> 304: ((*reinterpret_cast<jint*>(&con) & 0x7FFFFF) != 0);
>>
>> Why are you hand-crafting this check here? Is there not some predefined function to do this check?
>
> Does `g_isnan` not work here? If not, add a comment why :)
Nice suggestion!, Fixed.
>> test/hotspot/jtreg/compiler/c2/irTests/TestFloat16ScalarOperations.java line 63:
>>
>>> 61:
>>> 62: private static Generator<Float> genF = G.uniformFloats(0.0f, 70000.0f);
>>> 63: private static Generator<Short> genHF = G.uniformFloat16s(Float.floatToFloat16(-2000.0f), Float.floatToFloat16(2000.0f));
>>
>> Is there a good reason to only take the uniform distribution?
>>
>> https://github.com/openjdk/jdk/blob/4a491bef6636441f14fc8bbdedf65063fce038bd/test/hotspot/jtreg/compiler/lib/generators/Generators.java#L102-L105
>
> What about `NaN` and `infty` etc?
There are some value transforms which are sensitive to specific value range e.g.
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/subnode.cpp#L2020
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/divnode.cpp#L897
Choosing any random value will make it tricky to put hard IR checks in place, uniformFloat range is hitting right sweet spot for us.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24179#discussion_r2126466898
PR Review Comment: https://git.openjdk.org/jdk/pull/24179#discussion_r2126466086
More information about the hotspot-compiler-dev
mailing list