RFR: 8309502: RISC-V: String.indexOf intrinsic may produce misaligned memory loads [v2]
Fei Yang
fyang at openjdk.org
Thu Jun 8 02:54:52 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)`.
Ah, this won't save us any instructions. Let's change this code snippet: https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp#LL754-L757
into a single line: `slli(tmp3, result_tmp, haystack_chr_shift);`
-------------
PR Comment: https://git.openjdk.org/jdk/pull/14320#issuecomment-1581808899
More information about the hotspot-compiler-dev
mailing list