> On 14 Dec 2023, at 14:28, tender wang <tndrwang@gmail.com> wrote:
>
> Now that AND is more faster, Can we replace the '% SLRU_MAX_BANKLOCKS' operation in SimpleLruGetBankLock() with
'&127'
unsigned int GetBankno1(unsigned int pageno) {
return pageno & 127;
}
unsigned int GetBankno2(unsigned int pageno) {
return pageno % 128;
}
Generates with -O2
GetBankno1(unsigned int):
mov eax, edi
and eax, 127
ret
GetBankno2(unsigned int):
mov eax, edi
and eax, 127
ret
Compiler is smart enough with constants.
Best regards, Andrey Borodin.