From 8df5b5da5748d786307f54bd9a64ea79bce5f0d6 Mon Sep 17 00:00:00 2001 From: Thomas Debesse Date: Sat, 25 May 2024 20:18:06 +0200 Subject: [PATCH] fixup-always-define-sse --- src/common/Platform.h | 76 +++++++++++++++++++++---------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/src/common/Platform.h b/src/common/Platform.h index 13269a35c7..4f342fe15d 100644 --- a/src/common/Platform.h +++ b/src/common/Platform.h @@ -63,6 +63,39 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define __x86_64__ 1 #endif +#if defined(_MSC_VER) + /* Detect MSVC providing SSE and SSE2. + + MSVC doesn't set __SSE*__, and only sets _M_IX86_FP on i686. + We should look for _M_AMD64 or _M_X64 to know if SSE and SSE2 + are enabled when building code for amd64. Beware that _M_AMD64 + and _M_X64 are also enabled when building for ARM64EC: + + > - _M_AMD64 Defined as the integer literal value 100 for compilations + > that target x64 processors or ARM64EC. Otherwise, undefined. + > - _M_X64 Defined as the integer literal value 100 for compilations + > that target x64 processors or ARM64EC. Otherwise, undefined. + > - _M_ARM64EC Defined as 1 for compilations that target ARM64EC. + > Otherwise, undefined. + > -- https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170 + + It is unclear if xmmintrin.h is available on ARM64EC. */ + + #if defined(_M_IX86_FP) + #if _M_IX86_FP >= 2 + #define __SSE__ 1 + #define __SSE2__ 1 + #elif _M_IX86_FP == 1 + #define __SSE__ 1 + #endif + #elif defined(_M_AMD64) || defined(_M_X64) + #if !defined(_M_ARM64EC) + #define __SSE__ 1 + #define __SSE2__ 1 + #endif + #endif +#endif + /* The definition name syntax is: DAEMON_USE_ARCH_INTRINSICS_[_extension] Examples: @@ -81,45 +114,12 @@ The definitions for the architecture itself are automatically set by CMake. */ #if defined(DAEMON_USE_ARCH_INTRINSICS) // Set architecture extensions definitions. - #if defined(_MSC_VER) - /* Detect MSVC providing SSE and SSE2. - - MSVC doesn't set __SSE*__, and only sets _M_IX86_FP on i686. - We should look for _M_AMD64 or _M_X64 to know if SSE and SSE2 - are enabled when building code for amd64. Beware that _M_AMD64 - and _M_X64 are also enabled when building for ARM64EC: - - > - _M_AMD64 Defined as the integer literal value 100 for compilations - > that target x64 processors or ARM64EC. Otherwise, undefined. - > - _M_X64 Defined as the integer literal value 100 for compilations - > that target x64 processors or ARM64EC. Otherwise, undefined. - > - _M_ARM64EC Defined as 1 for compilations that target ARM64EC. - > Otherwise, undefined. - > -- https://learn.microsoft.com/en-us/cpp/preprocessor/predefined-macros?view=msvc-170 - - It is unclear if xmmintrin.h is available on ARM64EC. */ - - #if defined(_M_IX86_FP) - #if _M_IX86_FP >= 2 - #define DAEMON_USE_ARCH_INTRINSICS_i686_sse - #define DAEMON_USE_ARCH_INTRINSICS_i686_sse2 - #elif _M_IX86_FP == 1 - #define DAEMON_USE_ARCH_INTRINSICS_i686_sse - #endif - #elif defined(_M_AMD64) || defined(_M_X64) - #if !defined(_M_ARM64EC) - #define DAEMON_USE_ARCH_INTRINSICS_i686_sse - #define DAEMON_USE_ARCH_INTRINSICS_i686_sse2 - #endif - #endif - #else - #if defined(__SSE__) || defined(MSVC_SSE) - #define DAEMON_USE_ARCH_INTRINSICS_i686_sse - #endif + #if defined(__SSE__) + #define DAEMON_USE_ARCH_INTRINSICS_i686_sse + #endif - #if defined(__SSE2__) || defined(MSVC_SSE2) - #define DAEMON_USE_ARCH_INTRINSICS_i686_sse2 - #endif + #if defined(__SSE2__) + #define DAEMON_USE_ARCH_INTRINSICS_i686_sse2 #endif // Include intrinsics-specific headers.