Skip to content

Commit

Permalink
Rename libpopcount64(x) to popcnt64_bitwise(x)
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Mar 17, 2024
1 parent f166bcc commit 99214a4
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions libpopcnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* population count) in an array as quickly as possible using
* specialized CPU instructions i.e. POPCNT, AVX2, AVX512, NEON.
*
* Copyright (c) 2016 - 2020, Kim Walisch
* Copyright (c) 2016 - 2024, Kim Walisch
* Copyright (c) 2016 - 2018, Wojciech Muła
*
* All rights reserved.
Expand Down Expand Up @@ -149,7 +149,7 @@ extern "C" {
* It uses 12 arithmetic operations, one of which is a multiply.
* http://en.wikipedia.org/wiki/Hamming_weight#Efficient_implementation
*/
static inline uint64_t libpopcount64(uint64_t x)
static inline uint64_t popcnt64_bitwise(uint64_t x)
{
uint64_t m1 = 0x5555555555555555ll;
uint64_t m2 = 0x3333333333333333ll;
Expand Down Expand Up @@ -222,7 +222,7 @@ static inline uint64_t popcnt64(uint64_t x)

static inline uint64_t popcnt64(uint64_t x)
{
return libpopcount64(x);
return popcnt64_bitwise(x);
}

#endif
Expand Down Expand Up @@ -645,14 +645,14 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
* We use unaligned memory accesses here to improve performance.
*/
for (; i < size - size % 8; i += 8)
cnt += libpopcount64(*(const uint64_t*)(ptr + i));
cnt += popcnt64_bitwise(*(const uint64_t*)(ptr + i));

if (i < size)
{
uint64_t val = 0;
size_t bytes = (size_t)(size - i);
memcpy(&val, &ptr[i], bytes);
cnt += libpopcount64(val);
cnt += popcnt64_bitwise(val);
}

return cnt;
Expand Down Expand Up @@ -750,7 +750,7 @@ static inline uint64_t popcnt(const void* data, uint64_t size)
uint64_t val = 0;
size_t bytes = (size_t)(size - i);
memcpy(&val, &ptr[i], bytes);
cnt += libpopcount64(val);
cnt += popcnt64_bitwise(val);
}

return cnt;
Expand Down

0 comments on commit 99214a4

Please sign in to comment.