Merge pull request #8749 from ikopylov/function-bitCount-Int16-Int8-perf

bitCount performance: special handling for Int16 and Int8
This commit is contained in:
alexey-milovidov 2020-01-21 00:12:34 +03:00 committed by GitHub
commit c4e2d71b48
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));
}