Compare commits
2 commits
1a17235ffd
...
740cf37552
Author | SHA1 | Date | |
---|---|---|---|
![]() |
740cf37552 | ||
![]() |
ab57a1d621 |
1 changed files with 1 additions and 4 deletions
|
@ -52,10 +52,7 @@ uint64_t randomx_reciprocal(uint64_t divisor) {
|
||||||
|
|
||||||
uint64_t quotient = p2exp63 / divisor, remainder = p2exp63 % divisor;
|
uint64_t quotient = p2exp63 / divisor, remainder = p2exp63 % divisor;
|
||||||
|
|
||||||
unsigned bsr = 0; //highest set bit in divisor
|
unsigned bsr = 64 - __builtin_clzll(divisor); //highest set bit in divisor
|
||||||
|
|
||||||
for (uint64_t bit = divisor; bit > 0; bit >>= 1)
|
|
||||||
bsr++;
|
|
||||||
|
|
||||||
for (unsigned shift = 0; shift < bsr; shift++) {
|
for (unsigned shift = 0; shift < bsr; shift++) {
|
||||||
if (remainder >= divisor - remainder) {
|
if (remainder >= divisor - remainder) {
|
||||||
|
|
Loading…
Reference in a new issue