|
|
|
|
|
by fweimer
1200 days ago
|
|
It's possible to use a lookup table (sort of) in a register. With x86-64-v2 and later, the code is larger, but potentially faster due to the shorter dependency chain: int
div7 (int x)
{
return 9 - __builtin_popcountll (0x4081020408102040ULL >> x);
} https://godbolt.org/z/Wj6P6jYGM I think any monotonic function on 0 .. 63 can be written this way, so should be possible to fold in the outer 63 - nlz expression, too. |
|