RFR: 8282664: Unroll by hand StringUTF16 and StringLatin1 polynomial hash loops [v4]
Ludovic Henry
luhenry at openjdk.org
Tue Nov 1 06:19:25 UTC 2022
On Mon, 31 Oct 2022 22:06:20 GMT, Claes Redestad <redestad at openjdk.org> wrote:
>> No you don't need to, the vector loop can be calculated as:
>>
>> IntVector accumulation = IntVector.zero(INT_SPECIES);
>> for (int i = 0; i < bound; i += INT_SPECIES.length()) {
>> IntVector current = IntVector.load(INT_SPECIES, array, i);
>> accumulation = accumulation.mul(31**(INT_SPECIES.length())).add(current);
>> }
>> return accumulation.mul(IntVector.of(31**INT_SPECIES.length() - 1, ..., 31**2, 31, 1).reduce(ADD);
>>
>> Each iteration only requires a multiplication and an addition. The weight of lanes can be calculated just before the reduction operation.
>
> Ok, I can try rewriting as @merykitty suggests and compare. I'm running out of time to spend on this right now, though, so I sort of hope we can do this experiment as a follow-up RFE.
@cl4es i can write the assembly and send it your way if you want
-------------
PR: https://git.openjdk.org/jdk/pull/10847
More information about the hotspot-dev
mailing list