RFR: 8302908: RISC-V: Support masked vector arithmetic instructions for Vector API [v12]

Dingli Zhang dzhang at openjdk.org
Fri Apr 14 15:48:40 UTC 2023


On Thu, 6 Apr 2023 16:42:20 GMT, Dingli Zhang <dzhang at openjdk.org> wrote:

>> src/hotspot/cpu/riscv/riscv_v.ad line 2422:
>> 
>>> 2420: %}
>>> 2421: 
>>> 2422: instruct vmask_gen_I(vRegMask dst, iRegI src) %{
>> 
>> Just a reminder that your following new rules will enable array operations partial inlining. Have you tested this feature on RISC-V?
>
> I am sorry I misunderstood you before, currently riscv does not have arraycopy partial inlining enabled like aarch64[1] because we did not add all the nodes needed for the above optimization in this patch[2].
> 
> We added the required nodes and tested `org/openjdk/bench/java/lang/ArrayCopyAligned.java`, the arraycopy partial inline function tested correctly and the corresponding nodes could be printed in the compilation log as follows:
> 
> 124     B23: # out( B24 ) <- in( B22 )  Freq: 0.402723
> 124     # castII of R8, #@castII
> 124     vmask_gen_I V0, R8
> 134     loadV_masked V1, V0, [R10]
> 140     storeV_masked [R11], V0, V1
> 
> However, because of the lack of hardware data, we do not turn on the partial inlining optimization by default for now, as the partial inline optimization depends on the nodes we will append.
> 
> We are testing more extensively, and will update the PR after that.
> 
> [1] https://github.com/openjdk/jdk/blob/cd7d53c88c27eedbe16020b88c2219708d170a1e/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp#L557-L563
> [2] https://github.com/openjdk/jdk/blob/cd7d53c88c27eedbe16020b88c2219708d170a1e/src/hotspot/share/opto/macroArrayCopy.cpp#L220-L225

> Just a reminder that your following new rules will enable array operations partial inlining. Have you tested this feature on RISC-V?

FYI: We enable array operations partial inlining on riscv with the patch below, tier1-3 looks fine.


diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp
index 82f34ade0ef..6cbb8b61b6a 100644
--- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp
+++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp
@@ -320,6 +320,14 @@ void VM_Version::c2_initialize() {
   if (FLAG_IS_DEFAULT(UseMontgomerySquareIntrinsic)) {
     FLAG_SET_DEFAULT(UseMontgomerySquareIntrinsic, true);
   }
+
+  int inline_size = (UseRVV && MaxVectorSize >= 16) ? MaxVectorSize : 0;
+  if (FLAG_IS_DEFAULT(ArrayOperationPartialInlineSize)) {
+    FLAG_SET_DEFAULT(ArrayOperationPartialInlineSize, inline_size);
+  } else if (ArrayOperationPartialInlineSize != 0 && ArrayOperationPartialInlineSize != inline_size) {
+    warning("Setting ArrayOperationPartialInlineSize to %d", inline_size);
+    ArrayOperationPartialInlineSize = inline_size;
+  }
 }
 #endif // COMPILER2

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

PR Review Comment: https://git.openjdk.org/jdk/pull/12682#discussion_r1166997854


More information about the hotspot-compiler-dev mailing list