RFR: 8352585: Add special case handling for Float16.max/min x86 backend [v6]

Sandhya Viswanathan sviswanathan at openjdk.org
Fri Mar 28 22:17:22 UTC 2025


On Fri, 28 Mar 2025 21:17:21 GMT, Sandhya Viswanathan <sviswanathan at openjdk.org> wrote:

>> test/hotspot/jtreg/compiler/intrinsics/float16/TestFloat16MaxMinSpecialValues.java line 58:
>> 
>>> 56:         if (Float16.isNaN(actual) && Float16.isNaN(expected)) {
>>> 57:             return false;
>>> 58:         }
>> 
>> This should be:
>>         if (Float16.isNaN(actual) ^ Float16.isNaN(expected)) {
>>             return true;
>>         }
>
> Basically assert if one is NaN and other is not.

On further thought what you have also works. Though we could simplify the assertionCheck method to just one statement:
public static boolean assertionCheck(Float16 actual, Float16 expected) {
   return !actual.equals(expected);
}
This is because, the equals method takes care of NaNs. The [equals](https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/lang/Double.html#equals(java.lang.Object)) uses [representation equivalence](https://docs.oracle.com/en/java/javase/24/docs/api/java.base/java/lang/Double.html#repEquivalence), defining NaN arguments to be equal to each other.

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/24169#discussion_r2019488902


More information about the hotspot-compiler-dev mailing list