cpu: only run SSE code when supported

Check if we can run SSE instructions before executing the denormals
SSE code.

Fixes #1775
This commit is contained in:
Wim Taymans 2021-11-02 20:11:07 +01:00
parent 7d9b49293c
commit 84ecebbd4e

View file

@ -184,13 +184,18 @@ x86_init(struct impl *impl)
static int x86_zero_denormals(void *object, bool enable) static int x86_zero_denormals(void *object, bool enable)
{ {
#if defined(HAVE_SSE) #if defined(HAVE_SSE)
unsigned int mxcsr; struct impl *impl = object;
mxcsr = _mm_getcsr(); if (impl->flags & SPA_CPU_FLAG_SSE) {
if (enable) unsigned int mxcsr;
mxcsr |= 0x8040; mxcsr = _mm_getcsr();
else if (enable)
mxcsr &= ~0x8040; mxcsr |= 0x8040;
_mm_setcsr(mxcsr); else
mxcsr &= ~0x8040;
_mm_setcsr(mxcsr);
spa_log_debug(impl->log, "%p: zero-denormals:%s",
impl, enable ? "on" : "off");
}
return 0; return 0;
#else #else
return -ENOTSUP; return -ENOTSUP;