RFR: 8308277: RISC-V: Improve vectorization of Match.sqrt() on floats

Feilong Jiang fjiang at openjdk.org
Fri May 19 00:49:53 UTC 2023


On Wed, 17 May 2023 12:56:04 GMT, Fei Yang <fyang at openjdk.org> wrote:

>> [JDK-8190800](https://bugs.openjdk.org/browse/JDK-8190800) added `VSqrtF` and `SqrtF` nodes to support the vectorization of Match.sqrt() on floats. For riscv port, however, the scalar version of `sqrtF` still uses the old match rule that converts Float to Double first. It can be simplified to just use `SqrtF`.
>> 
>> The old match rule also affects the vectorization of Math.sqrt() on float. The current implementation will convert float to double with `vcvtFtoD`, then do `vsqrtD`, and finally convert the result back to float with `vcvtDtoF`. If we use the new `SqrtF` match rule, it will only use `vsqrtF` to do the conversion. Take the test (Sqrt.java) from [JDK-8190800](https://bugs.openjdk.org/browse/JDK-8190800) as an example, here is the output with `-XX:+PrintOptoAssembly` and `-XX:+UseRVV`:
>> 
>> before:
>> 
>> 
>> 19a loadV V1, [R13] # vector (rvv)
>> 1a2 vcvtFtoD V2, V1
>> 1ae vfsqrt.v V1, V2 #@vsqrtD
>> 1b6 vcvtDtoF V1, V1
>> 1c2 storeV [R14], V1 # vector (rvv)
>> 
>> 
>> after:
>> 
>> 1be loadV V1, [R12] # vector (rvv)
>> 1c6 vfsqrt.v V1, V1 #@vsqrtF
>> 1ce addi R12, R29, #144 # ptr, #@addP_reg_imm
>> 1d2 storeV [R12], V1 # vector (rvv)
>> 
>> 
>> Testing:
>> - [x] tier1 tests on Unmatched board without `-XX:+UseRVV` (release build)
>> - [x] hotspot_tier1/jdk_tier1 on QEMU with `-XX:+UseRVV` (release build)
>
> Looks reasonable. Thanks.

@RealFYang -- Thanks!

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

PR Comment: https://git.openjdk.org/jdk/pull/14029#issuecomment-1553857011


More information about the hotspot-compiler-dev mailing list