File tree Expand file tree Collapse file tree 3 files changed +18
-24
lines changed
Expand file tree Collapse file tree 3 files changed +18
-24
lines changed Original file line number Diff line number Diff line change 22
33#include " platform.h"
44
5- // Macros wrapping intrinsics
6- #if defined(LIBHAT_X86_64)
7- #define LIBHAT_TZCNT64 (num ) _tzcnt_u64(num)
8- #define LIBHAT_BLSR64 (num ) _blsr_u64(num)
9- #elif defined(LIBHAT_X86)
10- #include < bit>
11- #define LIBHAT_TZCNT64 (num ) std::countl_zero(num)
12- #define LIBHAT_BLSR64 (num ) num & (num - 1 )
13- #endif
14-
155#ifdef _MSC_VER
16- #include < intrin.h>
17-
18- namespace hat ::detail {
19- inline unsigned long bsf (unsigned long num) noexcept {
20- unsigned long offset;
21- _BitScanForward (&offset, num);
22- return offset;
23- }
24- }
25-
266 #define LIBHAT_RETURN_ADDRESS () _ReturnAddress()
27- #define LIBHAT_BSF32 (num ) hat::detail::bsf(num)
287#else
298 #define LIBHAT_RETURN_ADDRESS () __builtin_extract_return_addr(__builtin_return_address(0 ))
30- #define LIBHAT_BSF32 (num ) __builtin_ctz(num)
319#endif
3210
3311#if __cpp_if_consteval >= 202106L
Original file line number Diff line number Diff line change @@ -63,7 +63,7 @@ namespace hat::detail {
6363 }
6464
6565 while (mask) {
66- const auto offset = LIBHAT_TZCNT64 (mask);
66+ const auto offset = _tzcnt_u64 (mask);
6767 const auto i = reinterpret_cast <const std::byte*>(&it) + offset - cmpIndex;
6868 if constexpr (veccmp) {
6969 const auto data = _mm512_loadu_si512 (i);
@@ -79,7 +79,7 @@ namespace hat::detail {
7979 return i;
8080 }
8181 }
82- mask = LIBHAT_BLSR64 (mask);
82+ mask = _blsr_u64 (mask);
8383 }
8484 }
8585
Original file line number Diff line number Diff line change 66
77#include < immintrin.h>
88
9+ #ifdef _MSC_VER
10+ #include < intrin.h>
11+
12+ namespace hat ::detail {
13+ inline unsigned long bsf (unsigned long num) noexcept {
14+ unsigned long offset;
15+ _BitScanForward (&offset, num);
16+ return offset;
17+ }
18+ }
19+
20+ #define LIBHAT_BSF32 (num ) hat::detail::bsf(num)
21+ #else
22+ #define LIBHAT_BSF32 (num ) __builtin_ctz(num)
23+ #endif
24+
925namespace hat ::detail {
1026
1127 inline void load_signature_128 (const signature_view signature, __m128i& bytes, __m128i& mask) {
You can’t perform that action at this time.
0 commit comments