cpu: add zero_denormals method

Add a method to enable/disable the denormals flush-to-zero and
denormals-as-zero CPU options.

Add a config option to make it possible to disable this again.

Fixes high CPU usage when dealing with denormals, which can happen
in many DSP functions.

Fixes #1681
This commit is contained in:
Wim Taymans 2021-10-11 14:54:48 +02:00
parent 036371c48f
commit 85d5c8cd6c
6 changed files with 70 additions and 3 deletions

View file

@ -176,3 +176,15 @@ x86_init(struct impl *impl)
return 0;
}
static int x86_zero_denormals(void *object, bool enable)
{
unsigned int mxcsr;
mxcsr = __builtin_ia32_stmxcsr();
if (enable)
mxcsr |= 0x8040;
else
mxcsr &= ~0x8040;
__builtin_ia32_ldmxcsr(mxcsr);
return 0;
}