On Mon, 22 Jun 2026 05:06:40 GMT, Jatin Bhateja <[email protected]> wrote:

>> As per the discussion on JDK-8370691-Float16Vector Support pull request 
>> https://github.com/openjdk/jdk/pull/28002#issuecomment-4652163477
>> adding the handling to Canonicalize NaN lane encodings held in Float16Vector 
>> lanes so that all NaN representations,
>> including signaling ones, computes the same hash code.
>> 
>> Kindly review and share your feedback.
>> 
>> Best Regards,
>> Jatin
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Jatin Bhateja has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Review comments resolution

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16Vector.java 
line 3750:

> 3748:                 a[i] = canonicalNaNBits;
> 3749:             }
> 3750:         }

This is too complicated, we don't need to optimize and avoid creating `Float16` 
instances (we are anyway already creating an intermediate array). Simplicity 
wins here, esp. since these methods will not be used in performant situations.

I originally proposed explicit conversion, but I think I would prefer to an 
internal `toFloat16Array` method and then we can express as:


return Objects.hash(species(), Arrays.hashCode(toFloat16Array()))


This offers two advantages:
1. The code shape closely resembles that which it will eventually be; and
2. We can reuse `toFloat16Array()` for `toString()`

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

PR Review Comment: https://git.openjdk.org/jdk/pull/31587#discussion_r3453646228

Reply via email to