From dff2a52a816c7f046ccceb59d91af43a8617b4be Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Sat, 29 Apr 2023 11:36:28 -0400 Subject: [PATCH] Small cleanups for the mul128.h header Testing using godbolt confirms that there is no need to use the "#pragma intrinsic" voodoo on MSVC 2022. Possibly this was required with older versions of the compiler. --- src/lib/utils/mul128.h | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/src/lib/utils/mul128.h b/src/lib/utils/mul128.h index 39bf8e104a4..9fc88b01425 100644 --- a/src/lib/utils/mul128.h +++ b/src/lib/utils/mul128.h @@ -12,11 +12,6 @@ #if defined(BOTAN_BUILD_COMPILER_IS_MSVC) && defined(BOTAN_TARGET_CPU_HAS_NATIVE_64BIT) #include - #if defined(_M_ARM64) - #pragma intrinsic(__umulh) - #else - #pragma intrinsic(_umul128) - #endif #endif namespace Botan { @@ -24,12 +19,8 @@ namespace Botan { #if defined(__SIZEOF_INT128__) && defined(BOTAN_TARGET_CPU_HAS_NATIVE_64BIT) #define BOTAN_TARGET_HAS_NATIVE_UINT128 - // Prefer TI mode over __int128 as GCC rejects the latter in pendantic mode - #if defined(__GNUG__) - typedef unsigned int uint128_t __attribute__((mode(TI))); - #else - typedef unsigned __int128 uint128_t; - #endif + // GCC complains if this isn't marked with __extension__ + __extension__ typedef unsigned __int128 uint128_t; #endif /** @@ -43,13 +34,12 @@ inline void mul64x64_128(uint64_t a, uint64_t b, uint64_t* lo, uint64_t* hi) *hi = (r >> 64) & 0xFFFFFFFFFFFFFFFF; *lo = (r ) & 0xFFFFFFFFFFFFFFFF; -#elif defined(BOTAN_BUILD_COMPILER_IS_MSVC) && defined(BOTAN_TARGET_CPU_HAS_NATIVE_64BIT) - #if defined(_M_ARM64) +#elif defined(BOTAN_BUILD_COMPILER_IS_MSVC) && defined(BOTAN_TARGET_ARCH_IS_X86_64) + *lo = _umul128(a, b, hi); + +#elif defined(BOTAN_BUILD_COMPILER_IS_MSVC) && defined(BOTAN_TARGET_ARCH_IS_ARM64) *lo = a * b; *hi = __umulh(a, b); - #else - *lo = _umul128(a, b, hi); - #endif #elif defined(BOTAN_USE_GCC_INLINE_ASM) && defined(BOTAN_TARGET_ARCH_IS_X86_64) asm("mulq %3"