3 #include "config_simd.h"
10 #if HAVE_SSE_INTRINSICS
11 #include <emmintrin.h>
13 #include <xmmintrin.h>
16 #if HAVE_SSE && !defined(_MM_DENORMALS_ZERO_MASK)
17 /* Some headers seem to be missing these? */
18 #define _MM_DENORMALS_ZERO_MASK 0x0040u
19 #define _MM_DENORMALS_ZERO_ON 0x0040u
22 #if !HAVE_SSE_INTRINSICS && HAVE_SSE
28 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
29 [[gnu::target("sse")]]
32 void disable_denormals(unsigned int *state
[[maybe_unused
]])
34 #if HAVE_SSE_INTRINSICS
35 *state
= _mm_getcsr();
36 unsigned int sseState
{*state
};
37 sseState
&= ~(_MM_FLUSH_ZERO_MASK
| _MM_DENORMALS_ZERO_MASK
);
38 sseState
|= _MM_FLUSH_ZERO_ON
| _MM_DENORMALS_ZERO_ON
;
43 *state
= _mm_getcsr();
44 unsigned int sseState
{*state
};
45 sseState
&= ~_MM_FLUSH_ZERO_MASK
;
46 sseState
|= _MM_FLUSH_ZERO_ON
;
47 if((CPUCapFlags
&CPU_CAP_SSE2
))
49 sseState
&= ~_MM_DENORMALS_ZERO_MASK
;
50 sseState
|= _MM_DENORMALS_ZERO_ON
;
56 #if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
57 [[gnu::target("sse")]]
60 void reset_fpu(unsigned int state
[[maybe_unused
]])
62 #if HAVE_SSE_INTRINSICS || HAVE_SSE
70 unsigned int FPUCtl::Set() noexcept
73 #if HAVE_SSE_INTRINSICS
74 disable_denormals(&state
);
76 if((CPUCapFlags
&CPU_CAP_SSE
))
77 disable_denormals(&state
);
82 void FPUCtl::Reset(unsigned int state
[[maybe_unused
]]) noexcept
84 #if HAVE_SSE_INTRINSICS
87 if((CPUCapFlags
&CPU_CAP_SSE
))