From 3e816de4fb3f8be4746643f5b9c5c07186e16b6c Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 18 Mar 2019 20:58:48 -0700 Subject: Use SSE intrinsics in a few more places --- OpenAL32/Include/alMain.h | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'OpenAL32') 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 #endif +#ifdef HAVE_SSE_INTRINSICS +#include +#endif #include #include @@ -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; -- cgit v1.2.3