aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2019-03-18 20:14:40 -0700
committerChris Robinson <[email protected]>2019-03-18 20:14:40 -0700
commit2de1d17bc6b07ec4e7680f1c46e147eeaa269f05 (patch)
tree69165764c92d16727267153ba5b2acd51a69381d
parent6a0b2ed0ca2b7628771ee450567c2c62c575db36 (diff)
Use SSE intrinsics to set FTZ and DAZ
-rw-r--r--Alc/fpu_modes.h2
-rw-r--r--Alc/helpers.cpp19
2 files changed, 18 insertions, 3 deletions
diff --git a/Alc/fpu_modes.h b/Alc/fpu_modes.h
index 1afd6618..8261692e 100644
--- a/Alc/fpu_modes.h
+++ b/Alc/fpu_modes.h
@@ -2,7 +2,7 @@
#define FPU_MODES_H
class FPUCtl {
-#if defined(__GNUC__) && defined(HAVE_SSE)
+#if defined(HAVE_SSE_INTRINSICS) || (defined(__GNUC__) && defined(HAVE_SSE))
unsigned int sse_state{};
#elif defined(HAVE___CONTROL87_2)
unsigned int state{};
diff --git a/Alc/helpers.cpp b/Alc/helpers.cpp
index 13ba3a2a..d5bbde1d 100644
--- a/Alc/helpers.cpp
+++ b/Alc/helpers.cpp
@@ -89,6 +89,9 @@ DEFINE_PROPERTYKEY(PKEY_AudioEndpoint_GUID, 0x1da5d803, 0xd492, 0x4edd, 0x8c, 0x
#ifdef HAVE_CPUID_H
#include <cpuid.h>
#endif
+#ifdef HAVE_SSE_INTRINSICS
+#include <xmmintrin.h>
+#endif
#ifdef HAVE_SYS_SYSCONF_H
#include <sys/sysconf.h>
#endif
@@ -261,7 +264,15 @@ void FillCPUCaps(int capfilter)
FPUCtl::FPUCtl() noexcept
{
-#if defined(__GNUC__) && defined(HAVE_SSE)
+#if defined(HAVE_SSE_INTRINSICS)
+ this->sse_state = _mm_getcsr();
+ unsigned int sseState = this->sse_state;
+ sseState |= 0x8000; /* set flush-to-zero */
+ sseState |= 0x0040; /* set denormals-are-zero */
+ _mm_setcsr(sseState);
+
+#elif defined(__GNUC__) && defined(HAVE_SSE)
+
if((CPUCapFlags&CPU_CAP_SSE))
{
__asm__ __volatile__("stmxcsr %0" : "=m" (*&this->sse_state));
@@ -290,7 +301,11 @@ void FPUCtl::leave() noexcept
{
if(!this->in_mode) return;
-#if defined(__GNUC__) && defined(HAVE_SSE)
+#if defined(HAVE_SSE_INTRINSICS)
+ _mm_setcsr(this->sse_state);
+
+#elif defined(__GNUC__) && defined(HAVE_SSE)
+
if((CPUCapFlags&CPU_CAP_SSE))
__asm__ __volatile__("ldmxcsr %0" : : "m" (*&this->sse_state));