mirror of
https://github.com/Z3Prover/z3
synced 2026-04-27 22:33:35 +00:00
Fix SMALL_BITS constant reference to use direct calculation instead
Co-authored-by: nunoplopes <2998477+nunoplopes@users.noreply.github.com>
This commit is contained in:
parent
23fe87612a
commit
7654ab4b72
1 changed files with 3 additions and 2 deletions
|
|
@ -2277,7 +2277,8 @@ unsigned mpz_manager<SYNCH>::power_of_two_multiple(mpz const & a) {
|
||||||
uint64_t v;
|
uint64_t v;
|
||||||
if (val == mpz::SMALL_INT_MIN) {
|
if (val == mpz::SMALL_INT_MIN) {
|
||||||
// SMALL_INT_MIN = -2^(SMALL_BITS-1), so it has (SMALL_BITS-1) trailing zeros
|
// SMALL_INT_MIN = -2^(SMALL_BITS-1), so it has (SMALL_BITS-1) trailing zeros
|
||||||
return mpz::SMALL_BITS - 1;
|
// On 32-bit: return 30, on 64-bit: return 62
|
||||||
|
return (sizeof(uintptr_t) * 8 - 1) - 1;
|
||||||
} else if (val < 0) {
|
} else if (val < 0) {
|
||||||
v = static_cast<uint64_t>(-val);
|
v = static_cast<uint64_t>(-val);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -2389,7 +2390,7 @@ unsigned mpz_manager<SYNCH>::mlog2(mpz const & a) {
|
||||||
// Special case: negating SMALL_INT_MIN would overflow
|
// Special case: negating SMALL_INT_MIN would overflow
|
||||||
// For 32-bit: SMALL_INT_MIN = -2^30, so log2(2^30) = 30
|
// For 32-bit: SMALL_INT_MIN = -2^30, so log2(2^30) = 30
|
||||||
// For 64-bit: SMALL_INT_MIN = -2^62, so log2(2^62) = 62
|
// For 64-bit: SMALL_INT_MIN = -2^62, so log2(2^62) = 62
|
||||||
return mpz::SMALL_BITS - 1;
|
return (sizeof(uintptr_t) * 8 - 1) - 1;
|
||||||
}
|
}
|
||||||
return uint64_log2(static_cast<uint64_t>(-v));
|
return uint64_log2(static_cast<uint64_t>(-v));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue