On Tue, 3 Nov 2026 17:40:23 GMT, Volodymyr Paprotski <[email protected]> 
wrote:

>> Larry has updated the pull request incrementally with one additional commit 
>> since the last revision:
>> 
>>   8394260: Refine Adler32 AVX2 loop
>>   
>>   Reduce the AVX2 hot loop to one conditional backedge and remove the 
>> redundant yprev_a copy by accumulating ya before updating it.
>>   
>>   Factor the modulo BASE sequence into a helper and extend the Adler32 JMH 
>> parameters to cover the small sizes.
>
> src/hotspot/cpu/x86/stubGenerator_x86_64_adler.cpp line 89:
> 
>> 87:   const int BASE = 65521;
>> 88:   const int DIV_BASE_MAGIC_SHIFT = 47;
>> 89:   const juint DIV_BASE_MAGIC = 2147975281U; // gcc magic for unsigned 
>> divide by 65521
> 
> - uint32_t I think instead of juint
> - its not "gcc magic"..  `// ceil(2^47 / 65521) `
> 
> I got tripped up by this, it looks deceptively like barett reduction.. but 
> barett does floor() instead of ceil().. and barett usually leaves result off 
> by a prime or three; your reduction is 'final' within the given inputs. 
> 
> Not sure if you considered it, but this prime is a pseudo-mersenne prime so 
> reduction could had been `low + 15*high`.. but you are left again with not 
> quite complete reduction (off by one prime).. two operations, probably just 
> fine for the intermediate reductions. meh, this algorithm isn't 'reduction 
> bound', so don't feel you have to spend time on mersenne reduction.

Thanks.  By “gcc magic”, I only meant to document where I got the constant: 
obtained 2147975281 by inspecting GCC’s assembly output for uint32_t x % 65521, 
was not trying to identify it as barrett reduction. Sorry for the misleading 
comment, I’ll rewrite it.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/33338#discussion_r4463065822

Reply via email to