[Libreoffice-commits] core.git: include/tools sc/source tools/source

Tomaž Vajngerl tomaz.vajngerl at collabora.co.uk
Fri Nov 13 07:38:00 PST 2015


 include/tools/cpuid.hxx                |    6 ++++++
 sc/source/core/inc/arraysumfunctor.hxx |   11 ++++++++++-
 tools/source/misc/cpuid.cxx            |    3 +--
 3 files changed, 17 insertions(+), 3 deletions(-)

New commits:
commit 2af4da0ea9ee0b029e89cf5ab65d378d426d1af1
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.co.uk>
Date:   Fri Nov 13 16:31:13 2015 +0100

    improve compile time SSE2 detection, fix broken android build
    
    Prereq. to enable runtime SSE2 detection is that the compiler
    supports it in the first place. MSVS and GCC use different
    compiler flags for this so use __LO_SSE2_AVAILABLE__ to make this
    build platform independent.
    
    emmintrin.h is unavailable on ARM Android so include this and
    compile the SSE2 specific code only when we are sure we can build
    SSE2 code (__LO_SSE2_AVAILABLE__ is defined).
    
    Change-Id: I212c4e0b99a314d087b9def822a81325b25f3469

diff --git a/include/tools/cpuid.hxx b/include/tools/cpuid.hxx
index 2445129..348724e 100644
--- a/include/tools/cpuid.hxx
+++ b/include/tools/cpuid.hxx
@@ -14,6 +14,12 @@
 #include <sal/config.h>
 #include <tools/toolsdllapi.h>
 
+#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) && defined(__SSE2__)
+#define __LO_SSE2_AVAILABLE__ 1
+#elif defined(_MSC_VER) && (defined(_M_AMD64) || (defined(_M_IX86) && defined(_M_IX86_FP) && _M_IX86_FP >= 2))
+#define __LO_SSE2_AVAILABLE__ 1
+#endif
+
 namespace tools
 {
 namespace cpuid
diff --git a/sc/source/core/inc/arraysumfunctor.hxx b/sc/source/core/inc/arraysumfunctor.hxx
index 776c514..34ccd81 100644
--- a/sc/source/core/inc/arraysumfunctor.hxx
+++ b/sc/source/core/inc/arraysumfunctor.hxx
@@ -11,9 +11,12 @@
 #ifndef INCLUDED_SC_SOURCE_CORE_INC_ARRAYSUMFUNCTOR_HXX
 #define INCLUDED_SC_SOURCE_CORE_INC_ARRAYSUMFUNCTOR_HXX
 
-#include <emmintrin.h>
 #include <tools/cpuid.hxx>
 
+#if defined(__LO_SSE2_AVAILABLE__)
+#include <emmintrin.h>
+#endif
+
 namespace sc
 {
 
@@ -67,6 +70,7 @@ public:
 private:
     inline double executeSSE2(size_t& i, const double* pCurrent) const
     {
+#if defined(__LO_SSE2_AVAILABLE__)
         double fSum = 0.0;
         size_t nRealSize = mnSize - i;
         size_t nUnrolledSize = nRealSize - (nRealSize % 8);
@@ -107,6 +111,11 @@ private:
             fSum += temp;
         }
         return fSum;
+#else
+        (void) i;
+        (void) pCurrent;
+        return 0.0;
+#endif
     }
 
     inline double executeUnrolled(size_t& i, const double* pCurrent) const
diff --git a/tools/source/misc/cpuid.cxx b/tools/source/misc/cpuid.cxx
index b4406be..5e052fb 100644
--- a/tools/source/misc/cpuid.cxx
+++ b/tools/source/misc/cpuid.cxx
@@ -16,8 +16,7 @@ namespace tools
 namespace cpuid
 {
 
-// First minimize to MSVC / GCC compat. compiler and x86 / x64 architecture
-#if (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))) || (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)))
+#if defined(__LO_SSE2_AVAILABLE__)
 
 namespace
 {


More information about the Libreoffice-commits mailing list