RFR: 8365206: RISC-V: compiler/c2/irTests/TestFloat16ScalarOperations.java is failing on riscv64 [v3]
Fei Yang
fyang at openjdk.org
Wed Aug 20 11:52:38 UTC 2025
On Wed, 20 Aug 2025 09:32:57 GMT, Hamlin Li <mli at openjdk.org> wrote:
>> Hi,
>> Can you help to review this patch?
>>
>> Currently implementation of conversion from float to float16 only preserve some significant bits of a NaN, which is not right in some cases.
>> As this (NaN conversion from float to float16) is already in the slow path, so I'll just fix it by preserving all significant bits in the same way as j.l.Float.floatToFloat16.
>> As current tests does not catch the issue, except of TestFloat16ScalarOperations.java, so add another test.
>>
>> There is also the similar issue in vector version of conversion from float to float16, I'll address it in another pr [JDK-8365772](https://bugs.openjdk.org/browse/JDK-8365772)
>>
>> Thanks!
>
> Hamlin Li has updated the pull request incrementally with one additional commit since the last revision:
>
> typo
Thanks for the quick update. Looks good modulo two minor comments about code style.
src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 5970:
> 5968: // bits into lower 9 bits of binary 16 significand.
> 5969: //
> 5970: // check j.l.Float.floatToFloat16 for more information.
Suggestion: `// Check j.l.Float.floatToFloat16 for more information.`
src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 5978:
> 5976: orr(tmp2, tmp2, tmp1);
> 5977: andi(tmp1, dst, 0xf);
> 5978: orr(dst, tmp2, tmp1);
Suggestion for adding some extra code comment to help understand the numbers:
// 10 bits
slli(tmp1, dst, 9 + 32);
srli(tmp1, tmp1, 9 + 32 + 13);
orr(tmp2, tmp2, tmp1);
// 9 bits
slli(tmp1, dst, 19 + 32);
srli(tmp1, tmp1, 19 + 32 + 4);
orr(tmp2, tmp2, tmp1);
// 4 bits
andi(tmp1, dst, 0xf);
orr(dst, tmp2, tmp1);
-------------
Marked as reviewed by fyang (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/26838#pullrequestreview-3136217621
PR Review Comment: https://git.openjdk.org/jdk/pull/26838#discussion_r2287913244
PR Review Comment: https://git.openjdk.org/jdk/pull/26838#discussion_r2287911692
More information about the hotspot-dev
mailing list