Skip to content

Commit

Permalink
Rename CPUID_POPCNT to HAS_CPUID_POPCNT
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Apr 2, 2024
1 parent 3f28e0f commit ef582e0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion include/CPUID.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ bool run_CPUID_POPCNT()
}

/// Initialized at startup
const bool CPUID_POPCNT = run_CPUID_POPCNT();
const bool HAS_CPUID_POPCNT = run_CPUID_POPCNT();

} // namespace

Expand Down
8 changes: 4 additions & 4 deletions include/popcnt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ inline uint64_t popcnt64(uint64_t x)

// On my AMD EPYC 7642 CPU using GCC 12 this runtime
// check incurs an overall overhead of about 1%.
if_likely(CPUID_POPCNT)
if_likely(HAS_CPUID_POPCNT)
{
__asm__("popcnt %1, %0" : "=r"(x) : "r"(x));
return x;
Expand All @@ -77,7 +77,7 @@ inline uint64_t popcnt64(uint64_t x)
}
#elif defined(__i386__)

if_likely(CPUID_POPCNT)
if_likely(HAS_CPUID_POPCNT)
{
uint32_t x0 = uint32_t(x);
uint32_t x1 = uint32_t(x >> 32);
Expand Down Expand Up @@ -129,7 +129,7 @@ inline uint64_t popcnt64(uint64_t x)
#if defined(HAS_POPCNT)
return __popcnt64(x);
#elif defined(ENABLE_CPUID_POPCNT)
if_likely(CPUID_POPCNT)
if_likely(HAS_CPUID_POPCNT)
return __popcnt64(x);
else
return popcnt64_bitwise(x);
Expand All @@ -154,7 +154,7 @@ inline uint64_t popcnt64(uint64_t x)
return __popcnt(uint32_t(x)) +
__popcnt(uint32_t(x >> 32));
#elif defined(ENABLE_CPUID_POPCNT)
if_likely(CPUID_POPCNT)
if_likely(HAS_CPUID_POPCNT)
return __popcnt(uint32_t(x)) +
__popcnt(uint32_t(x >> 32));
else
Expand Down
2 changes: 1 addition & 1 deletion test/CPUID.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int main()
#endif

#if defined(ENABLE_CPUID_POPCNT)
std::cout << "CPU supports POPCNT: " << (CPUID_POPCNT ? "yes" : "no") << std::endl;
std::cout << "CPU supports POPCNT: " << (HAS_CPUID_POPCNT ? "yes" : "no") << std::endl;
#endif

#endif
Expand Down

0 comments on commit ef582e0

Please sign in to comment.