RFR: 8310268: RISC-V: misaligned memory access in String.Compare intrinsic [v3]

Fei Yang fyang at openjdk.org
Mon Jul 24 12:11:41 UTC 2023


On Mon, 24 Jul 2023 09:54:15 GMT, Vladimir Kempik <vkempik at openjdk.org> wrote:

>> src/hotspot/cpu/riscv/stubGenerator_riscv.cpp line 2315:
>> 
>>> 2313:   void compare_string_8_x_LU(Register tmpL, Register tmpU, Register strL, Register strU, Label& DIFF) {
>>> 2314:     const Register tmp = x30;
>>> 2315:     __ ld(tmpL, Address(strL));
>> 
>> Could we make use of another tmp register (maybe `x7`) and use that as the destination register for `ld` instead? Then we could inflate_lo32/hi32 from this tmp register and put the result in `tmpL`. That way would help remove the two `mv` instructions here in this function and the one located at label `DIFF`.
>
> I have done it in a slightly different way, still removing all "mv"s you have mentioned

Ah, I see you used `t0` instead. I once considered that, but I would still suggest `x7` which would be safer. `t0` as a scratch register are implicitly clobbered/used by so many assembler functions that it's risky to keep a live value in it across assemblers like `inflate_lo32`. `x7` should be a better candidate here as it is only updated at label `CALCULATE_DIFFERENCE` in function generate_compare_long_string_different_encoding.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/14534#discussion_r1272175683


More information about the hotspot-dev mailing list