mirror of
https://github.com/Z3Prover/z3
synced 2026-07-15 11:35:42 +00:00
Handle ARM64EC in MSVC mul_overflows path
This commit is contained in:
parent
b778291aae
commit
a9725372a9
1 changed files with 3 additions and 3 deletions
|
|
@ -34,14 +34,14 @@ static bool mul_overflows(int64_t a, int64_t b, int64_t & result) {
|
|||
return std::ckd_mul(&result, a, b);
|
||||
#elif defined(__GNUC__)
|
||||
return __builtin_mul_overflow(a, b, &result);
|
||||
#elif defined(_MSC_VER) && !defined(_M_ARM64)
|
||||
// MSVC _mul128 intrinsic is unavailable when targeting ARM64.
|
||||
#elif defined(_MSC_VER) && !defined(_M_ARM64) && !defined(_M_ARM64EC)
|
||||
// MSVC _mul128 is available on the non-ARM64 targets that still use this path.
|
||||
__int64 high;
|
||||
result = _mul128(a, b, &high);
|
||||
// Overflow if high bits are not the sign extension of result
|
||||
return high != (result < 0 ? -1 : 0);
|
||||
#elif defined(_MSC_VER)
|
||||
// `-(v + 1) + 1` computes |v| without ever evaluating -INT64_MIN.
|
||||
// `-(v + 1) + 1` computes |v| even for INT64_MIN, where direct negation would overflow.
|
||||
uint64_t x = a < 0 ? static_cast<uint64_t>(-(a + 1)) + 1 : static_cast<uint64_t>(a);
|
||||
uint64_t y = b < 0 ? static_cast<uint64_t>(-(b + 1)) + 1 : static_cast<uint64_t>(b);
|
||||
bool is_neg = (a < 0) != (b < 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue