diff options
| author | a1xd <[email protected]> | 2020-07-22 19:34:13 -0400 |
|---|---|---|
| committer | a1xd <[email protected]> | 2020-07-22 19:34:13 -0400 |
| commit | 78156f34166c110fcad47aef166684b8e25ac4fa (patch) | |
| tree | b6121a5e1725639800c266c865f9067b3cd31a17 /common/x64-util.hpp | |
| parent | Add .gitignore and .gitattributes. (diff) | |
| download | rawaccel-0.1-test.tar.xz rawaccel-0.1-test.zip | |
Add project files.v0.1-test
Diffstat (limited to 'common/x64-util.hpp')
| -rw-r--r-- | common/x64-util.hpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/common/x64-util.hpp b/common/x64-util.hpp new file mode 100644 index 0000000..2fb61bb --- /dev/null +++ b/common/x64-util.hpp @@ -0,0 +1,22 @@ +#pragma once + +#include <emmintrin.h> + +inline double sqrtsd(double val) { + __m128d src = _mm_load_sd(&val); + __m128d dst = _mm_sqrt_sd(src, src); + _mm_store_sd(&val, dst); + return val; +} + +inline constexpr double minsd(double a, double b) { + return (a < b) ? a : b; +} + +inline constexpr double maxsd(double a, double b) { + return (b < a) ? a : b; +} + +inline constexpr double clampsd(double v, double lo, double hi) { + return minsd(maxsd(v, lo), hi); +} |