On Sat, 19 Sep 2026 05:32:35 GMT, Mohamed Issa <[email protected]> wrote:

>> It turns out the 2-step FP16 to integral conversion process is usually more 
>> beneficial on platforms that support AVX10.2 instructions. This is mainly 
>> due to the reduced instruction count and automatic special case handling 
>> (e.g., NaN). With that in mind, the changes in this PR go back to the 
>> original approach when AVX10.2 is detected in the C2 compiler except for the 
>> FP16 to Byte case. That path now uses a direct conversion instruction from 
>> the AVX10.2 ISA. There are also some updates to the JTREG tests and JMH 
>> benchmarks.
>> 
>> The JTREG test listed below was used to verify correctness with 
>> `-XX:-UseSuperWord` and `-XX:+UseSuperWord` JVM options applied. All 
>> modifications and tests used [OpenJDK 
>> v28-b15](https://github.com/openjdk/jdk/releases/tag/jdk-28%2B15) as the 
>> baseline build.
>> 
>> 1. 
>> `jtreg:test/hotspot/jtreg/compiler/vectorapi/TestFloat16ToIntegralConv.java`
>> 
>> ---------
>> - [x] I confirm that I make this contribution in accordance with the 
>> [OpenJDK Interim AI Policy](https://openjdk.org/legal/ai).
>
> Mohamed Issa has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Use AVX10.2 fp16 to byte direct conversion vector instruction whenever 
> possible.

src/hotspot/cpu/x86/x86.ad line 22089:

> 22087: %}
> 22088: 
> 22089: instruct castHFtoB_reg_avx10_2(vec dst, vec src) %{

Using direct conversion instruction from Float16 to Bytes will saturate all the 
values above 127 or less than -128, while in the two step process (byte) 
float16ToFloat(value) ,  value is first converted from float16 to Float, then 
float to integer followed by truncation,  since value range of float16 is 
subset of integer value range hence  VCVTTPS2DQ will only result into 
exceptional value (0x80000000) for NaN and +/-Inf.

src/hotspot/cpu/x86/x86.ad line 22101:

> 22099:   ins_pipe( pipe_slow );
> 22100: %}
> 22101: 

Attached test case fails with the patch.
[TestConvHF2BVec.java](https://github.com/user-attachments/files/32451005/TestConvHF2BVec.java)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/32957#discussion_r4059306700
PR Review Comment: https://git.openjdk.org/jdk/pull/32957#discussion_r4059315104

Reply via email to