RFR: 8308277: RISC-V: Improve vectorization of Match.sqrt() on floats
Fei Yang
fyang at openjdk.org
Wed May 17 12:58:42 UTC 2023
On Wed, 17 May 2023 11:00:07 GMT, Feilong Jiang <fjiang 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:
> - [ ] tier1 tests on Unmatched board without `-XX:+UseRVV` (release build)
> - [ ] hotspot_tier1/jdk_tier1 on QEMU with `-XX:+UseRVV` (release build)
Looks reasonable. Thanks.
-------------
Marked as reviewed by fyang (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/14029#pullrequestreview-1430621322
More information about the hotspot-compiler-dev
mailing list