fast_urem_by_const: #ifdef DEBUG an assertion.

util_fast_urem32 is used in the hot path of hashmap lookups and this
asserts causes noticeable overhead. The correctness of this code should
be well exercised both from testing and mathematical proofs, so gate
this assertion behind #ifdef DEBUG.

Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14168>
This commit is contained in:
Tatsuyuki Ishi 2021-12-13 16:10:45 +09:00 committed by Marge Bot
parent c2e6569b46
commit 9f7e57ce98

View file

@ -68,7 +68,9 @@ util_fast_urem32(uint32_t n, uint32_t d, uint64_t magic)
{
uint64_t lowbits = magic * n;
uint32_t result = _mul32by64_hi(d, lowbits);
#ifdef DEBUG
assert(result == n % d);
#endif
return result;
}