mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-31 12:31:45 +01:00
Rewrite mulh64/umulh64
Use __int128_t/__uint128_t idioms on GCC/Clang. May result in better codegen by avoiding inline asm.
This commit is contained in:
parent
688aabc6c9
commit
eae5b9e049
@ -157,18 +157,18 @@ namespace utils
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline u64 umulh64(u64 a, u64 b)
|
constexpr u64 umulh64(u64 a, u64 b)
|
||||||
{
|
{
|
||||||
u64 result;
|
const __uint128_t x = a;
|
||||||
__asm__("mulq %[b]" : "=d"(result) : [a] "a"(a), [b] "rm"(b));
|
const __uint128_t y = b;
|
||||||
return result;
|
return (x * y) >> 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline s64 mulh64(s64 a, s64 b)
|
constexpr s64 mulh64(s64 a, s64 b)
|
||||||
{
|
{
|
||||||
s64 result;
|
const __int128_t x = a;
|
||||||
__asm__("imulq %[b]" : "=d"(result) : [a] "a"(a), [b] "rm"(b));
|
const __int128_t y = b;
|
||||||
return result;
|
return (x * y) >> 64;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user