RFR: 8309502: RISC-V: String.indexOf intrinsic may produce misaligned memory loads [v2]
Vladimir Kempik
vkempik at openjdk.org
Thu Jun 8 05:49:07 UTC 2023
On Wed, 7 Jun 2023 18:09:51 GMT, Vladimir Kempik <vkempik at openjdk.org> wrote:
>> Vladimir Kempik has updated the pull request incrementally with one additional commit since the last revision:
>>
>> make DO2 read by one character from memory per loop
>
> Numbers on DO4 ( comparing 4 characters at once) ( substring has to be final String of 4 characters)
> DO4:
>
> hifive
> Benchmark Mode Cnt Score Error Units
> before
> StringIndexOf.advancedWithShortSub4Chars avgt 25 69514.891 ± 128.730 ns/op
> after
> StringIndexOf.advancedWithShortSub4Chars avgt 25 2481.448 ± 13.481 ns/op
>
> thead
>
> Benchmark Mode Cnt Score Error Units
> before
> StringIndexOf.advancedWithShortSub4Chars avgt 25 753.125 ? 2.859 ns/op
> after
> StringIndexOf.advancedWithShortSub4Chars avgt 25 741.031 ? 9.075 ns/op
> @VladimirKempik : Thanks for the update. Would you mind one more tweak? Since `needle_chr_shift` and `haystack_chr_shift` could be 0 for the L case, I think we should guard the shift instructions at https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L634, https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L637, https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L679, https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L700, https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L724, https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#L775 with conditions `if (needle_chr_shift)` or `if (haystack_chr_shift)`.
It's questionable, mv(Xd, Xs) becomes addi(Xd, Xs, 0).
and what is chearper - addi(Xd, Xs,0) or slli(Xd, Xs,0) is an open question.
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14320#issuecomment-1581924217
More information about the hotspot-compiler-dev
mailing list