RFR: 8350960: RISC-V: Add riscv backend for Float16 operations - vectorization

Hamlin Li mli at openjdk.org
Tue May 13 13:29:55 UTC 2025


On Tue, 13 May 2025 03:16:56 GMT, Fei Yang <fyang at openjdk.org> wrote:

>> Hi,
>> Can you help to review this patch?
>> It's a follow-up of https://github.com/openjdk/jdk/commit/9a3f9997b68a1f64e53b9711b878fb073c3c9b90.
>> Thanks!
>> 
>> ## Test
>> 
>> performance test running in progress ...
>
> src/hotspot/cpu/riscv/riscv_v.ad line 125:
> 
>> 123:         return UseZvfh;
>> 124:       case Op_FmaVHF:
>> 125:         return UseZvfh && UseFMA;
> 
> Maybe group with the existing two cases at L98 and L99 (Op_VectorCastHF2F / Op_VectorCastF2HF)?

Make sense, will fix.

> src/hotspot/cpu/riscv/riscv_v.ad line 382:
> 
>> 380:   ins_encode %{
>> 381:     assert(UseZvfh, "must");
>> 382:     BasicType bt = Matcher::vector_element_basic_type(this);
> 
> Question: What is `bt` calculated here? Seems there isn't one for HF16 in `enum BasicType` definition in file src/hotspot/share/utilities/globalDefinitions.hpp. I only see `T_FLOAT` and `T_DOUBLE`, which I don't think is usable here as we need to set SEW=16 for this instruction.

No, it uses T_SHORT instead, in Float16.java it also uses a short as underlying payload.
And if you check the generated assembly code, you'll find some code like `vsetivli        t0,16,e16,m1,tu,mu`.

To avoid confusion, I will add an assertion here so that it can be understood later.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25181#discussion_r2086829723
PR Review Comment: https://git.openjdk.org/jdk/pull/25181#discussion_r2086829293


More information about the hotspot-compiler-dev mailing list