[riscv-port] RFR: 8278644: riscv: Intrinsify mulAdd

Fei Yang fyang at openjdk.java.net
Tue Dec 21 08:44:33 UTC 2021


On Tue, 21 Dec 2021 01:15:43 GMT, Feilong Jiang <fjiang at openjdk.org> wrote:

> BigInteger intrinsic: mulAdd intrinsic is missed in current vm. It should be implemented.
> The JMH test of mulAdd intrinsic on the matched board shows that the performance can be improved by 0.69%~21.91% when the length of BigInteger changed from 1 to 5000, compared with that of C2.
> JMH test: [MyBenchmark.java](https://bugs.openjdk.java.net/secure/attachment/97414/MyBenchmark.java)
> 
> Performed full jtreg test with qemu without new failures.
> 
> Results list as follows
> | length | intrinsic(ops/ms) | no intrinsic(ops/ms) | intrinsic / no intrinsic |
> | ------ | ------ | ------ | ------ | 
> | 1 | 1643.111 | 1623.814 | 1.18% |
> | 2 | 1597.927 | 1585.216 | 0.80% |
> | 3 | 1542.249 | 1502.455 | 2.65% |
> | 5 | 1533.371 | 1522.837 | 0.69% |
> | 10 | 1377.683 | 1361.718 | 1.17% |
> | 50 | 925.826 | 844.276 | 9.62% |
> | 100 | 638.767 | 576.276 | 10.84% |
> | 1000 | 99.870 | 84.796 | 17.78% |
> | 2000 | 51.511 | 43.624 | 18.08% |
> | 5000 | 18.017 | 14.779 | 21.91% |

Changes requested by fyang (Lead).

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 3049:

> 3047:                              Register len, Register k, Register tmp) {
> 3048:   Label L_tail_loop, L_unroll, L_end;
> 3049:   mv(tmp, out);

I think this "mv" instruction could be moved after the zero check for"len". Then we will save one instruction when "len" is zero.

src/hotspot/cpu/riscv/macroAssembler_riscv.cpp line 3062:

> 3060:   blt(len, tmp, L_tail_loop);
> 3061:   bind(L_unroll);
> 3062:   for (unsigned i = 0; i < unroll; i++) {

Better to change type of "i" into signed, i.e., "for (int i = 0; i < unroll; i++)"

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

PR: https://git.openjdk.java.net/riscv-port/pull/36


More information about the riscv-port-dev mailing list