On Mon, 2 Mar 2026 22:53:04 GMT, Joe Darcy <[email protected]> wrote:

>> src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16.java 
>> line 1075:
>> 
>>> 1073:      */
>>> 1074:     public static boolean equivalent(Float16 f1, Float16 f2) {
>>> 1075:         return Float.equivalent(f1.floatValue(), f2.floatValue());
>> 
>> Maybe use `Float16.float16ToShortBits(…)` instead, matching 
>> `Float16​::equals(…)`, which avoids the `Float16` to `float` conversion:
>> https://github.com/openjdk/jdk/blob/49f14eb9fca155319d5475019715189e9f65dffd/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16.java#L936-L939
>> 
>> Suggestion:
>> 
>>         return float16ToShortBits(f1) == float16ToShortBits(f2);
>
> Yes; that would be another valid way to write this method.

I strongly recommend making this change, as the `Float16` to `float` conversion 
is expensive compared to the simple field read in `float16ToShortBits`.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29870#discussion_r2921944307

Reply via email to