aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/effects/pshifter.cpp12
-rw-r--r--OpenAL32/Include/alMain.h18
2 files changed, 22 insertions, 8 deletions
diff --git a/Alc/effects/pshifter.cpp b/Alc/effects/pshifter.cpp
index c76cd6a8..aa7dae87 100644
--- a/Alc/effects/pshifter.cpp
+++ b/Alc/effects/pshifter.cpp
@@ -20,6 +20,10 @@
#include "config.h"
+#ifdef HAVE_SSE_INTRINSICS
+#include <emmintrin.h>
+#endif
+
#include <cmath>
#include <cstdlib>
#include <array>
@@ -48,8 +52,12 @@ using complex_d = std::complex<double>;
inline int double2int(double d)
{
-#if ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) && \
- !defined(__SSE2_MATH__)) || (defined(_MSC_VER) && defined(_M_IX86_FP) && _M_IX86_FP < 2)
+#if defined(HAVE_SSE_INTRINSICS)
+ return _mm_cvttsd_si32(_mm_set_sd(d));
+
+#elif ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) && \
+ !defined(__SSE2_MATH__)) || (defined(_MSC_VER) && defined(_M_IX86_FP) && _M_IX86_FP < 2)
+
int sign, shift;
int64_t mant;
union {
diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h
index 39163ce3..f3761a5b 100644
--- a/OpenAL32/Include/alMain.h
+++ b/OpenAL32/Include/alMain.h
@@ -15,6 +15,9 @@
#ifdef HAVE_INTRIN_H
#include <intrin.h>
#endif
+#ifdef HAVE_SSE_INTRINSICS
+#include <xmmintrin.h>
+#endif
#include <array>
#include <vector>
@@ -196,10 +199,10 @@ struct bs2b;
* change it on its own threads. On some systems, a truncating conversion may
* always be the fastest method.
*/
-inline ALint fastf2i(ALfloat f) noexcept
+inline int fastf2i(float f) noexcept
{
-#if defined(HAVE_INTRIN_H) && ((defined(_M_IX86_FP) && (_M_IX86_FP > 0)) || defined(_M_X64))
- return _mm_cvt_ss2si(_mm_set1_ps(f));
+#if defined(HAVE_SSE_INTRINSICS)
+ return _mm_cvt_ss2si(_mm_set_ss(f));
#elif defined(_MSC_VER) && defined(_M_IX86_FP)
@@ -210,7 +213,7 @@ inline ALint fastf2i(ALfloat f) noexcept
#elif (defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__))
- ALint i;
+ int i;
#ifdef __SSE_MATH__
__asm__("cvtss2si %1, %0" : "=r"(i) : "x"(f));
#else
@@ -236,8 +239,11 @@ inline ALint fastf2i(ALfloat f) noexcept
/* Converts float-to-int using standard behavior (truncation). */
inline int float2int(float f) noexcept
{
-#if ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) && \
- !defined(__SSE_MATH__)) || (defined(_MSC_VER) && defined(_M_IX86_FP) && _M_IX86_FP == 0)
+#if defined(HAVE_SSE_INTRINSICS)
+ return _mm_cvtt_ss2si(_mm_set_ss(f));
+
+#elif ((defined(__GNUC__) || defined(__clang__)) && (defined(__i386__) || defined(__x86_64__)) && \
+ !defined(__SSE_MATH__)) || (defined(_MSC_VER) && defined(_M_IX86_FP) && _M_IX86_FP == 0)
ALint sign, shift, mant;
union {
ALfloat f;