diff options
author | Changqing Jing <changqing.jing@bmw.com> | 2024-09-19 22:27:45 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-19 07:27:45 -0700 |
commit | 54b3f5fbd5cc851b4efe1b6ffd3331612c87c0e9 (patch) | |
tree | e5021dc2f2127cd5ebd9c017da34bb020e82d155 | |
parent | 1c2b5bf29676c91da197df08bd7cd414c7090766 (diff) | |
download | wabt-54b3f5fbd5cc851b4efe1b6ffd3331612c87c0e9.tar.gz wabt-54b3f5fbd5cc851b4efe1b6ffd3331612c87c0e9.tar.bz2 wabt-54b3f5fbd5cc851b4efe1b6ffd3331612c87c0e9.zip |
Use intrinsic for Popcount on arm64 msvc (#2468)
-rw-r--r-- | src/config.h.in | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/src/config.h.in b/src/config.h.in index f7187c32..99628748 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -208,24 +208,11 @@ inline int Ctz(unsigned __int64 mask) { #endif } -#if _M_ARM64 -//https://stackoverflow.com/a/70012905 -template <typename T> -int BrianKernighanPopcount(T value) { - int count; - for(count = 0; value; count++) - { - value &= value - 1; - } - return count; -} -#endif - inline int Popcount(unsigned long value) { #if _M_X64 || _M_IX86 return __popcnt(value); #elif _M_ARM64 - return BrianKernighanPopcount(value); + return _CountOneBits(value); #else #error unexpected architecture #endif @@ -245,7 +232,7 @@ inline int Popcount(unsigned __int64 value) { #elif _M_IX86 return Popcount(HighDword(value)) + Popcount(LowDword(value)); #elif _M_ARM64 - return BrianKernighanPopcount(value); + return _CountOneBits64(value); #else #error unexpected architecture #endif |