From 64b269015958e7e44fcd42a730614d6dc6e48f55 Mon Sep 17 00:00:00 2001 From: Reece Date: Thu, 27 Jan 2022 20:52:55 +0000 Subject: [PATCH] [*] Major -> AuMin/AuMax was returning a reference??? [*] Added arch x64 check around _mm_popcnt_u64. might export msvc only symbol from CpuId w/ the has smid requirement for this one op --- Include/AuroraUtils.hpp | 51 +++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 28 deletions(-) diff --git a/Include/AuroraUtils.hpp b/Include/AuroraUtils.hpp index 00479633..2a0aff58 100644 --- a/Include/AuroraUtils.hpp +++ b/Include/AuroraUtils.hpp @@ -67,26 +67,6 @@ T AuExchange(T &obj, U &&new_value) return AURORA_RUNTIME_EXCHANGE(obj, new_value); } -#if !defined(AURORA_RUNTIME_MIN) -#define AURORA_RUNTIME_MIN std::min -#endif - -template< class T > -constexpr const T &AuMin(const T &a, const T &b) -{ - return AURORA_RUNTIME_MIN(a, b); -} - -#if !defined(AURORA_RUNTIME_MAX) -#define AURORA_RUNTIME_MAX std::max -#endif - -template< class T > -constexpr const T &AuMax(const T &a, const T &b) -{ - return AURORA_RUNTIME_MAX(a, b); -} - #if !defined(AURORA_RUNTIME_MEMCMP) #define AURORA_RUNTIME_MEMCMP std::memcmp #endif @@ -664,6 +644,18 @@ auto AuTuplePopFront(const Tuple& tuple) return AuTuplePopFrontImpl(tuple, std::make_index_sequence::value - 1>()); } +template +constexpr const T AuMin(const T &a, const T &b) +{ + return a < b ? a : b; +} + +template +constexpr const T AuMax(const T &a, const T &b) +{ + return a > b ? b : a; +} + template static auline bool AuTestBit(T value, AuUInt8 idx) { @@ -799,14 +791,17 @@ template static AuUInt8 AuPopCnt(T in) { #if defined(AURORA_COMPILER_MSVC) -#if defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86) - if constexpr (sizeof(T) == sizeof(AuUInt64)) - return _mm_popcnt_u64(in); - else if constexpr (sizeof(T) < sizeof(AuUInt32)) - return __popcnt(in); - else if constexpr (sizeof(T) <= sizeof(AuUInt16)) - return __popcnt16(in); -#endif + #if defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86) + #if defined(AURORA_ARCH_X64) + if constexpr (sizeof(T) == sizeof(AuUInt64)) + return _mm_popcnt_u64(in); + else + #endif + if constexpr (sizeof(T) < sizeof(AuUInt32)) + return __popcnt(in); + else if constexpr (sizeof(T) <= sizeof(AuUInt16)) + return __popcnt16(in); + #endif #else if constexpr (sizeof(T) == sizeof(unsigned long long)) return __builtin_popcountll(static_cast(value));