aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-03-18 20:58:48 -0700
committerChris Robinson <[email protected]>2019-03-18 20:58:48 -0700
commit3e816de4fb3f8be4746643f5b9c5c07186e16b6c (patch)
treeced2f8e0ee5f6f163ac84524c98a113c77e1949f /OpenAL32
parent73a43fb19c2f8eeb724094ec0fb84088513450f7 (diff)
Use SSE intrinsics in a few more places
Diffstat (limited to 'OpenAL32')
-rw-r--r--OpenAL32/Include/alMain.h18
1 files changed, 12 insertions, 6 deletions
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;