[riscv-port-jdk17u:riscv-port] RFR: 8308277: RISC-V: Improve vectorization of Match.sqrt() on floats

Feilong Jiang fjiang at openjdk.org
Mon May 22 11:27:37 UTC 2023


Hi,
Please review this clean backport of [JDK-8308277](https://bugs.openjdk.org/browse/JDK-8308277).

For jdk17u, `Math.sqrt(float)` will not get vectorized even when `UseRVV` is true without the `SqrtF` node.

Here is the OptoAssembly of Sqrt.java from [JDK-8190800](https://bugs.openjdk.org/browse/JDK-8190800):

before:

120     B14: #  out( B14 B15 ) <- in( B13 B14 ) Loop( B14-B14 inner main of N91 strip mined) Freq: 1.86254e+07
120 +   addw  R28, R12, zr  #@convI2L_reg_reg
124 +   slli  R28, R28, (#2 & 0x3f) #@lShiftL_reg_imm
128 +   add R28, R18, R28   # ptr, #@addP_reg_reg
12c +   flw  F0, [R28, #16] # float, #@loadF
130 +   fsqrt.s  F1, F0 #@sqrtF_reg
134 +   fsw  F1, [R28, #16] # float, #@storeF


after:

140     B14: #  out( B14 B15 ) <- in( B13 B14 ) Loop( B14-B14 inner main of N93 strip mined) Freq: 1.60517e+07
140     addw  R10, R31, zr  #@convI2L_reg_reg
144     slli  R10, R10, (#2 & 0x3f) #@lShiftL_reg_imm
148     add R11, R9, R10    # ptr, #@addP_reg_reg
14c     addi  R10, R11, #16 # ptr, #@addP_reg_imm
150     vle V1, [R10]   #@loadV
158     vfsqrt.v V1, V1 #@vsqrtF
160     addi  R10, R11, #16 # ptr, #@addP_reg_imm
164     vse V1, [R10]   #@storeV

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

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

Changes: https://git.openjdk.org/riscv-port-jdk17u/pull/58/files
 Webrev: https://webrevs.openjdk.org/?repo=riscv-port-jdk17u&pr=58&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8308277
  Stats: 1 line in 1 file changed: 0 ins; 0 del; 1 mod
  Patch: https://git.openjdk.org/riscv-port-jdk17u/pull/58.diff
  Fetch: git fetch https://git.openjdk.org/riscv-port-jdk17u.git pull/58/head:pull/58

PR: https://git.openjdk.org/riscv-port-jdk17u/pull/58


More information about the riscv-port-dev mailing list