mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-16 23:17:29 +00: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
|
||||
}
|
||||
|
||||
inline u64 umulh64(u64 a, u64 b)
|
||||
constexpr u64 umulh64(u64 a, u64 b)
|
||||
{
|
||||
u64 result;
|
||||
__asm__("mulq %[b]" : "=d"(result) : [a] "a"(a), [b] "rm"(b));
|
||||
return result;
|
||||
const __uint128_t x = a;
|
||||
const __uint128_t y = b;
|
||||
return (x * y) >> 64;
|
||||
}
|
||||
|
||||
inline s64 mulh64(s64 a, s64 b)
|
||||
constexpr s64 mulh64(s64 a, s64 b)
|
||||
{
|
||||
s64 result;
|
||||
__asm__("imulq %[b]" : "=d"(result) : [a] "a"(a), [b] "rm"(b));
|
||||
return result;
|
||||
const __int128_t x = a;
|
||||
const __int128_t y = b;
|
||||
return (x * y) >> 64;
|
||||
}
|
||||
|
||||
#elif defined(_MSC_VER)
|
||||
|
Loading…
Reference in New Issue
Block a user