diff --git a/src/system.cpp b/src/system.cpp index 7c889c46..325ab92e 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -31,6 +31,8 @@ #include #endif +#include // for _mm_getcsr etc + #include #include #if defined ARCH_MAC @@ -971,7 +973,7 @@ void setFpuFlags(uint32_t flags) { } void resetFpuFlags() { - uint32_t flags = 0; + uint32_t flags = getFpuFlags(); #if defined ARCH_X64 // Set CPU to flush-to-zero (FTZ) and denormals-are-zero (DAZ) mode @@ -981,11 +983,13 @@ void resetFpuFlags() { // _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); flags |= 0x0040; // Round-to-nearest is default + flags &= ~0x6000; #elif defined ARCH_ARM64 // Set Flush-to-Zero flags |= 1 << 24; // ARM64 always uses DAZ // Round-to-nearest is default + flags &= ~((1 << 22) | (1 << 23)); #endif setFpuFlags(flags);