From 7ee6fa6487f01271c4374e4c260466b5041afe72 Mon Sep 17 00:00:00 2001 From: Tomaž Vajngerl Date: Sat, 20 Jun 2020 16:59:59 +0200 Subject: Add test as an example how to add CPU intrinsics support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also makes sure that if the CPU dataction or compiler detection doesn't work correctly, the test could potentially crash. Change-Id: If0862c0a736c8e1f5ba1117b248918e4c1fb2f4d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96779 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl --- include/tools/simdsupport.hxx | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'include/tools') diff --git a/include/tools/simdsupport.hxx b/include/tools/simdsupport.hxx index 4ef7a698089e..5d10d53d48ad 100644 --- a/include/tools/simdsupport.hxx +++ b/include/tools/simdsupport.hxx @@ -14,6 +14,8 @@ // code using intrinsics or not. So we have to (re)set them again // every time this file has been included. +// In other words... DO NOT ADD "#pragma once" here + #undef LO_SSE2_AVAILABLE #undef LO_SSSE3_AVAILABLE #undef LO_AVX_AVAILABLE @@ -24,49 +26,48 @@ // SSE2 is required for X64 #if (defined(_M_X64) || defined(_M_IX86_FP) && _M_IX86_FP >= 2) #define LO_SSE2_AVAILABLE +#include #endif // end SSE2 // compiled with /arch:AVX #if defined(__AVX__) #ifndef LO_SSE2_AVAILABLE #define LO_SSE2_AVAILABLE +#include #endif #define LO_SSSE3_AVAILABLE #define LO_AVX_AVAILABLE -#endif // defined(__AVX__) +#include +#endif // end defined(__AVX__) // compiled with /arch:AVX2 #if defined(__AVX2__) #define LO_AVX2_AVAILABLE +#include #endif // defined(__AVX2__) #else // compiler Clang and GCC #if defined(__SSE2__) || defined(__x86_64__) // SSE2 is required for X64 #define LO_SSE2_AVAILABLE +#include #endif // defined(__SSE2__) #if defined(__SSSE3__) #define LO_SSSE3_AVAILABLE +#include #endif // defined(__SSSE3__) #if defined(__AVX__) #define LO_AVX_AVAILABLE +#include #endif // defined(__AVX__) #if defined(__AVX2__) #define LO_AVX2_AVAILABLE +#include #endif // defined(__AVX2__) #endif // end compiler Clang and GCC -// If we detect any SIMD intrinsics, include the headers automatically -#if defined(LO_SSE2_AVAILABLE) -#include -#elif defined(LO_SSSE3_AVAILABLE) -#include -#elif defined(LO_AVX_AVAILABLE) || defined(LO_AVX2_AVAILABLE) -#include -#endif - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit