From bf650ec32b6a8464c5d770f719361f2366bfe881 Mon Sep 17 00:00:00 2001 From: Laurent GIORELLO <124622149+laurent-onenano@users.noreply.github.com> Date: Fri, 10 Nov 2023 04:24:17 +0100 Subject: [PATCH] Update umul128_upper64 to use optimised x64 version of umul128 From the previous commit, we can use an improved version to calculate the product of two unsigned 64 bits integers. umul128 will benefit from this update as well. --- include/fmt/format.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/fmt/format.h b/include/fmt/format.h index fbdd06c2..526410dc 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -1535,7 +1535,9 @@ inline int floor_log2_pow10(int e) noexcept { // Computes upper 64 bits of multiplication of two 64-bit unsigned integers. inline uint64_t umul128_upper64(uint64_t x, uint64_t y) noexcept { -#if FMT_USE_INT128 +#if __x86_64__ && (__GNUC__ || __clang__) + return umul128(x, y).high(); +#elif FMT_USE_INT128 auto p = static_cast(x) * static_cast(y); return static_cast(p >> 64); #elif defined(_MSC_VER) && defined(_M_X64)