|
15 | 15 | #ifndef QMATH_HELPERS_H |
16 | 16 | #define QMATH_HELPERS_H |
17 | 17 |
|
18 | | -#if defined __has_include |
19 | | -#if __has_include(<xmmintrin.h>) && __has_include(<pmmintrin.h>) |
20 | | -#include <xmmintrin.h> |
21 | | -#include <pmmintrin.h> |
22 | | -#if defined(_MM_FLUSH_ZERO_OFF) && defined(_MM_DENORMALS_ZERO_ON) |
| 18 | +#if !(defined(__ARM_NEON) || defined(__aarch64__)) && __has_include(<xmmintrin.h>) // clang-format off |
| 19 | + #include <xmmintrin.h> |
| 20 | + #if __has_include(<pmmintrin.h>) |
| 21 | + #include <pmmintrin.h> |
| 22 | + #endif |
| 23 | +#elif __has_include(<cfenv>) |
| 24 | + #include <cfenv> |
| 25 | +#endif |
| 26 | + |
23 | 27 | static void disable_denormals() |
24 | 28 | { |
25 | | - _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); |
26 | | - _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); |
| 29 | +#if !(defined(__ARM_NEON) || defined(__aarch64__)) && __has_include(<xmmintrin.h>) // clang-format off |
| 30 | + #if defined(_MM_FLUSH_ZERO_OFF) && defined(_MM_DENORMALS_ZERO_ON) |
| 31 | + _MM_SET_FLUSH_ZERO_MODE(_MM_FLUSH_ZERO_ON); |
| 32 | + _MM_SET_DENORMALS_ZERO_MODE(_MM_DENORMALS_ZERO_ON); |
| 33 | + #else |
| 34 | + #ifndef _MM_FLUSH_ZERO_ON |
| 35 | + #define _MM_FLUSH_ZERO_ON 0x8000 |
| 36 | + #endif |
| 37 | + #ifndef _MM_DENORMALS_ZERO_ON |
| 38 | + #define _MM_DENORMALS_ZERO_ON 0x0040 |
| 39 | + #endif |
| 40 | + _mm_setcsr(_mm_getcsr() | (_MM_FLUSH_ZERO_ON | _MM_DENORMALS_ZERO_ON)); |
| 41 | + #endif |
| 42 | +#elif __has_include(<cfenv>) && defined(FE_DFL_DISABLE_SSE_DENORMS_ENV) |
| 43 | + fesetenv(FE_DFL_DISABLE_SSE_DENORMS_ENV); |
| 44 | +#endif // clang-format on |
27 | 45 | } |
28 | | -#define XMM_HAS_DENORMAL_DEACTIVATE |
29 | | -#endif |
30 | | -#endif |
31 | | -#endif |
32 | | -#ifdef XMM_HAS_DENORMAL_DEACTIVATE |
33 | | -#undef XMM_HAS_DENORMAL_DEACTIVATE |
34 | | -#else |
35 | | -static void disable_denormals() {} |
36 | | -#endif |
37 | 46 |
|
38 | 47 | #endif |
0 commit comments