Simplify utils::umulh64 (MSVC)
This commit is contained in:
+3
-10
@@ -249,20 +249,13 @@ namespace utils
|
|||||||
{
|
{
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
if (std::is_constant_evaluated())
|
if (std::is_constant_evaluated())
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
u128 a = (u32)x * (u64)(u32)y;
|
return static_cast<u64>((u128{x} * u128{y}) >> 64);
|
||||||
u128 b = (x >> 32) * (u32)y;
|
|
||||||
u128 c = (u32)x * (y >> 32);
|
|
||||||
u128 d = (x >> 32) * (y >> 32);
|
|
||||||
a += (b << 32);
|
|
||||||
a += (c << 32);
|
|
||||||
a.hi += d.lo;
|
|
||||||
return a.hi;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
return __umulh(x, y);
|
return __umulh(x, y);
|
||||||
#else
|
|
||||||
return (u128{x} * u128{y}) >> 64;
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user