9 #ifdef HAVE_SSE_INTRINSICS
10 #include <emmintrin.h>
11 #elif defined(HAVE_SSE)
12 #include <xmmintrin.h>
15 #if defined(HAVE_SSE) && !defined(_MM_DENORMALS_ZERO_MASK)
16 /* Some headers seem to be missing these? */
17 #define _MM_DENORMALS_ZERO_MASK 0x0040u
18 #define _MM_DENORMALS_ZERO_ON 0x0040u
25 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
26 [[gnu::target("sse")]]
29 void disable_denormals(unsigned int *state
[[maybe_unused
]])
31 #if defined(HAVE_SSE_INTRINSICS)
32 *state
= _mm_getcsr();
33 unsigned int sseState
{*state
};
34 sseState
&= ~(_MM_FLUSH_ZERO_MASK
| _MM_DENORMALS_ZERO_MASK
);
35 sseState
|= _MM_FLUSH_ZERO_ON
| _MM_DENORMALS_ZERO_ON
;
38 #elif defined(HAVE_SSE)
40 *state
= _mm_getcsr();
41 unsigned int sseState
{*state
};
42 sseState
&= ~_MM_FLUSH_ZERO_MASK
;
43 sseState
|= _MM_FLUSH_ZERO_ON
;
44 if((CPUCapFlags
&CPU_CAP_SSE2
))
46 sseState
&= ~_MM_DENORMALS_ZERO_MASK
;
47 sseState
|= _MM_DENORMALS_ZERO_ON
;
53 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
54 [[gnu::target("sse")]]
57 void reset_fpu(unsigned int state
[[maybe_unused
]])
59 #if defined(HAVE_SSE_INTRINSICS) || defined(HAVE_SSE)
67 unsigned int FPUCtl::Set() noexcept
70 #if defined(HAVE_SSE_INTRINSICS)
71 disable_denormals(&state
);
72 #elif defined(HAVE_SSE)
73 if((CPUCapFlags
&CPU_CAP_SSE
))
74 disable_denormals(&state
);
79 void FPUCtl::Reset(unsigned int state
[[maybe_unused
]]) noexcept
81 #if defined(HAVE_SSE_INTRINSICS)
83 #elif defined(HAVE_SSE)
84 if((CPUCapFlags
&CPU_CAP_SSE
))