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

Feilong Jiang fjiang at openjdk.org
Fri May 19 00:52:56 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:
> - [x] tier1 tests on Unmatched board without `-XX:+UseRVV` (release build)
> - [x] hotspot_tier1/jdk_tier1 on QEMU with `-XX:+UseRVV` (release build)

This pull request has now been integrated.

Changeset: e520cdc8
Author:    Feilong Jiang <fjiang at openjdk.org>
Committer: Fei Yang <fyang at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/e520cdc882a778260181a2162a01ceff7cc41ca0
Stats:     1 line in 1 file changed: 0 ins; 0 del; 1 mod

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

Reviewed-by: fyang

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

PR: https://git.openjdk.org/jdk/pull/14029


More information about the hotspot-compiler-dev mailing list