bitCount performance: special handling for Int16 and Int8

This commit is contained in:
ikopylov 2020-01-20 19:36:03 +03:00 committed by GitHub
parent 1e72b37a21
commit f5f36f0199
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -20,6 +20,10 @@ struct BitCountImpl
return __builtin_popcountll(a);
if constexpr (std::is_same_v<A, UInt32> || std::is_same_v<A, Int32> || std::is_unsigned_v<A>)
return __builtin_popcount(a);
if constexpr (std::is_same_v<A, Int16>)
return __builtin_popcount(static_cast<UInt16>(a));
if constexpr (std::is_same_v<A, Int8>)
return __builtin_popcount(static_cast<UInt8>(a));
else
return __builtin_popcountll(ext::bit_cast<unsigned long long>(a));
}