Skip to content

Commit

Permalink
Reduce code bloat
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Jul 11, 2024
1 parent 17f3844 commit 2dd6268
Showing 1 changed file with 1 addition and 13 deletions.
14 changes: 1 addition & 13 deletions include/popcnt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ namespace {
/// It uses 12 arithmetic operations, one of which is a multiply.
/// http://en.wikipedia.org/wiki/Hamming_weight#Efficient_implementation
///
inline uint64_t popcnt64_bitwise(uint64_t x)
NOINLINE uint64_t popcnt64_bitwise(uint64_t x)
{
uint64_t m1 = 0x5555555555555555ull;
uint64_t m2 = 0x3333333333333333ull;
Expand Down Expand Up @@ -63,13 +63,7 @@ ALWAYS_INLINE uint64_t popcnt64(uint64_t x)
return x;
}
else
{
// On x86 and x64 CPUs when using the GCC compiler
// __builtin_popcount*(x) is slow (not inlined function call)
// when compiling without -mpopcnt. Therefore we avoid
// using __builtin_popcount*(x) here.
return popcnt64_bitwise(x);
}
}

} // namespace
Expand All @@ -89,13 +83,7 @@ ALWAYS_INLINE uint64_t popcnt64(uint64_t x)
return x0 + x1;
}
else
{
// On x86 and x64 CPUs when using the GCC compiler
// __builtin_popcount*(x) is slow (not inlined function call)
// when compiling without -mpopcnt. Therefore we avoid
// using __builtin_popcount*(x) here.
return popcnt64_bitwise(x);
}
}

} // namespace
Expand Down

0 comments on commit 2dd6268

Please sign in to comment.