diff options
author | kmosienko <kmosienko@yandex-team.ru> | 2022-02-10 16:46:53 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:53 +0300 |
commit | 3f323c9df018d4e22aed7bfb99d27749b8c1d180 (patch) | |
tree | 49e222ea1c5804306084bb3ae065bb702625360f /library/cpp/pop_count | |
parent | b5a9a2b99dd4fa6005304f0f60f4005137f18cb3 (diff) | |
download | ydb-3f323c9df018d4e22aed7bfb99d27749b8c1d180.tar.gz |
Restoring authorship annotation for <kmosienko@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'library/cpp/pop_count')
-rw-r--r-- | library/cpp/pop_count/popcount.cpp | 8 | ||||
-rw-r--r-- | library/cpp/pop_count/popcount.h | 38 |
2 files changed, 23 insertions, 23 deletions
diff --git a/library/cpp/pop_count/popcount.cpp b/library/cpp/pop_count/popcount.cpp index 4d34575ffb..49276424be 100644 --- a/library/cpp/pop_count/popcount.cpp +++ b/library/cpp/pop_count/popcount.cpp @@ -1,8 +1,8 @@ #include "popcount.h" -#include <util/system/defaults.h> +#include <util/system/defaults.h> #include <util/system/yassert.h> - + #include <string.h> static const ui8 PopCountLUT8Impl[1 << 8] = { @@ -10,7 +10,7 @@ static const ui8 PopCountLUT8Impl[1 << 8] = { #define B4(n) B2(n), B2(n + 1), B2(n + 1), B2(n + 2) #define B6(n) B4(n), B4(n + 1), B4(n + 1), B4(n + 2) B6(0), B6(1), B6(1), B6(2)}; - + ui8 const* PopCountLUT8 = PopCountLUT8Impl; #if !defined(_MSC_VER) @@ -25,6 +25,6 @@ static const ui8 PopCountLUT16Impl[1 << 16] = { #define B12(n) B10(n), B10(n + 1), B10(n + 1), B10(n + 2) #define B14(n) B12(n), B12(n + 1), B12(n + 1), B12(n + 2) B14(0), B14(1), B14(1), B14(2)}; - + ui8 const* PopCountLUT16 = PopCountLUT16Impl; #endif diff --git a/library/cpp/pop_count/popcount.h b/library/cpp/pop_count/popcount.h index d6f12d7a19..3d67737ed2 100644 --- a/library/cpp/pop_count/popcount.h +++ b/library/cpp/pop_count/popcount.h @@ -1,15 +1,15 @@ -#pragma once - +#pragma once + #include <util/generic/typelist.h> #include <util/system/cpu_id.h> -#include <util/system/defaults.h> +#include <util/system/defaults.h> #include <util/system/hi_lo.h> -#include <util/system/platform.h> - +#include <util/system/platform.h> + #if defined(_MSC_VER) #include <intrin.h> -#endif - +#endif + static inline ui32 PopCountImpl(ui8 n) { #if defined(_ppc64_) ui32 r; @@ -23,20 +23,20 @@ static inline ui32 PopCountImpl(ui8 n) { return PopCountLUT8[n]; #endif } - + static inline ui32 PopCountImpl(ui16 n) { #if defined(_MSC_VER) return __popcnt16(n); -#else +#else extern ui8 const* PopCountLUT16; return PopCountLUT16[n]; -#endif +#endif } - + static inline ui32 PopCountImpl(ui32 n) { #if defined(_MSC_VER) return __popcnt(n); -#else +#else #if defined(_x86_64_) if (NX86::CachedHavePOPCNT()) { ui32 r; @@ -62,13 +62,13 @@ static inline ui32 PopCountImpl(ui32 n) { #endif return PopCountImpl((ui16)Lo16(n)) + PopCountImpl((ui16)Hi16(n)); -#endif +#endif } - + static inline ui32 PopCountImpl(ui64 n) { #if defined(_MSC_VER) && !defined(_i386_) return __popcnt64(n); -#else +#else #if defined(_x86_64_) if (NX86::CachedHavePOPCNT()) { ui64 r; @@ -94,12 +94,12 @@ static inline ui32 PopCountImpl(ui64 n) { #endif return PopCountImpl((ui32)Lo32(n)) + PopCountImpl((ui32)Hi32(n)); -#endif +#endif } - + template <class T> static inline ui32 PopCount(T n) { using TCvt = TFixedWidthUnsignedInt<T>; - + return PopCountImpl((TCvt)n); -} +} |