[Mesa-dev] [PATCH 3/3] util: Use SSE rounding on all platforms that support it.

Jose Fonseca jfonseca at vmware.com
Sun Aug 9 03:57:45 PDT 2015


As currently only GCC x86_64 builds where using it.
---
 src/util/rounding.h | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/util/rounding.h b/src/util/rounding.h
index ec31b47..38c1c2f 100644
--- a/src/util/rounding.h
+++ b/src/util/rounding.h
@@ -27,7 +27,17 @@
 #include <math.h>
 #include <limits.h>
 
-#ifdef __x86_64__
+/* SSE2 is supported on: all x86_64 targets, on x86 targets when -msse2 is
+ * passed to GCC, and should also be enabled on all Windows builds. */
+#if defined(__x86_64__) /* gcc */ || \
+    defined(_M_X64) /* msvc */ || \
+    defined(_M_AMD64) /* msvc */ || \
+    defined(__SSE2__) /* gcc -msse2 */ || \
+    defined(_WIN32)
+#define HAVE_SSE2 1
+#endif
+
+#ifdef HAVE_SSE2
 #include <xmmintrin.h>
 #include <emmintrin.h>
 #endif
@@ -93,7 +103,7 @@ _mesa_roundeven(double x)
 static inline long
 _mesa_lroundevenf(float x)
 {
-#ifdef __x86_64__
+#ifdef HAVE_SSE2
 #if LONG_BIT == 64
    return _mm_cvtss_si64(_mm_load_ss(&x));
 #elif LONG_BIT == 32 || defined(_WIN32)
@@ -113,7 +123,7 @@ _mesa_lroundevenf(float x)
 static inline long
 _mesa_lroundeven(double x)
 {
-#ifdef __x86_64__
+#ifdef HAVE_SSE2
 #if LONG_BIT == 64
    return _mm_cvtsd_si64(_mm_load_sd(&x));
 #elif LONG_BIT == 32 || defined(_WIN32)
-- 
2.1.4



More information about the mesa-dev mailing list