RFR: 8320448: Accelerate IndexOf using AVX2 [v19]
Sandhya Viswanathan
sviswanathan at openjdk.org
Wed May 15 21:13:13 UTC 2024
On Sat, 4 May 2024 19:35:21 GMT, Scott Gibbons <sgibbons at openjdk.org> wrote:
>> Re-write the IndexOf code without the use of the pcmpestri instruction, only using AVX2 instructions. This change accelerates String.IndexOf on average 1.3x for AVX2. The benchmark numbers:
>>
>>
>> Benchmark Score Latest
>> StringIndexOf.advancedWithMediumSub 343.573 317.934 0.925375393x
>> StringIndexOf.advancedWithShortSub1 1039.081 1053.96 1.014319384x
>> StringIndexOf.advancedWithShortSub2 55.828 110.541 1.980027943x
>> StringIndexOf.constantPattern 9.361 11.906 1.271872663x
>> StringIndexOf.searchCharLongSuccess 4.216 4.218 1.000474383x
>> StringIndexOf.searchCharMediumSuccess 3.133 3.216 1.02649218x
>> StringIndexOf.searchCharShortSuccess 3.76 3.761 1.000265957x
>> StringIndexOf.success 9.186 9.713 1.057369911x
>> StringIndexOf.successBig 14.341 46.343 3.231504079x
>> StringIndexOfChar.latin1_AVX2_String 6220.918 12154.52 1.953814533x
>> StringIndexOfChar.latin1_AVX2_char 5503.556 5540.044 1.006629895x
>> StringIndexOfChar.latin1_SSE4_String 6978.854 6818.689 0.977049957x
>> StringIndexOfChar.latin1_SSE4_char 5657.499 5474.624 0.967675646x
>> StringIndexOfChar.latin1_Short_String 7132.541 6863.359 0.962260014x
>> StringIndexOfChar.latin1_Short_char 16013.389 16162.437 1.009307711x
>> StringIndexOfChar.latin1_mixed_String 7386.123 14771.622 1.999915517x
>> StringIndexOfChar.latin1_mixed_char 9901.671 9782.245 0.987938803
>
> Scott Gibbons has updated the pull request incrementally with one additional commit since the last revision:
>
> Rearrange; add lambdas for clarity
src/hotspot/cpu/x86/stubGenerator_x86_64_string.cpp line 1476:
> 1474: _masm);
> 1475:
> 1476: __ movq(r11, -1);
There doesn't seem to be a use of r11 below in this function.
src/hotspot/cpu/x86/stubGenerator_x86_64_string.cpp line 1493:
> 1491: // Assume r10 is n - k
> 1492: __ leaq(last, Address(haystack, r10, Address::times_1, isU ? -30 : -31));
> 1493: __ jmpb(temp);
Need to pass r10 as parameter. Also temp label could be given a better name.
src/hotspot/cpu/x86/stubGenerator_x86_64_string.cpp line 1502:
> 1500:
> 1501: __ cmpq(hsPtrRet, last);
> 1502: __ cmovq(Assembler::aboveEqual, hsPtrRet, last);
cmovq is expensive, better sequence would be:
__ cmpq(hsPtrRet, last);
__ jb_b(temp);
__ movq(hsPtrRet, last);
src/hotspot/cpu/x86/stubGenerator_x86_64_string.cpp line 1510:
> 1508: compare_big_haystack_to_needle(sizeKnown, size, NUMBER_OF_NEEDLE_BYTES_TO_COMPARE, loop_top, hsPtrRet, hsLength,
> 1509: needleLen, isU, DO_EARLY_BAILOUT, eq_mask, temp2, r10, _masm);
> 1510:
At this point hsLength is not the remaining length from hsPtrRet, would that cause a problem? If not, all the special paths in compare_big_haystack_to_needle need not be generated on this call.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1602016421
PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1601943761
PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1602251994
PR Review Comment: https://git.openjdk.org/jdk/pull/16753#discussion_r1602010926
More information about the hotspot-compiler-dev
mailing list