Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8308277

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

XMLWordPrintable

    • 21
    • b24
    • riscv
    • linux

        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 then 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 as an example:

        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)
        ```

              fjiang Feilong Jiang
              fjiang Feilong Jiang
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: