RFR: 8350960: RISC-V: Add riscv backend for Float16 operations - vectorization [v2]
Fei Yang
fyang at openjdk.org
Wed May 14 00:38:51 UTC 2025
On Tue, 13 May 2025 13:26:34 GMT, Hamlin Li <mli at openjdk.org> wrote:
>> 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.
Thanks for the answer. I see that is also reflected on the C2 source code [1].
Why not save this `Matcher::vector_element_basic_type(this)` call then? I mean:
assert(Matcher::vector_element_basic_type(this) == T_SHORT, "must");
__ vsetvli_helper(T_SHORT, Matcher::vector_length(this));
[1] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/vectornode.cpp#L63
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25181#discussion_r2087822782
More information about the hotspot-compiler-dev
mailing list