diff --git a/libpopcnt.h b/libpopcnt.h index c634f07..82fe2a1 100644 --- a/libpopcnt.h +++ b/libpopcnt.h @@ -527,10 +527,6 @@ static inline uint64_t popcnt_avx512(const uint64_t* ptr, const uint64_t size) */ static inline uint64_t popcnt(const void* data, uint64_t size) { - uint64_t i = 0; - uint64_t cnt = 0; - const uint8_t* ptr = (const uint8_t*) data; - /* * CPUID runtime checks are only enabled if this is needed. * E.g. CPUID is disabled when a user compiles his @@ -556,6 +552,10 @@ static inline uint64_t popcnt(const void* data, uint64_t size) #endif #endif + const uint8_t* ptr = (const uint8_t*) data; + uint64_t cnt = 0; + uint64_t i = 0; + #if defined(LIBPOPCNT_HAVE_AVX512) #if defined(__AVX512__) || \ (defined(__AVX512F__) && defined(__AVX512VPOPCNTDQ__)) @@ -569,11 +569,8 @@ static inline uint64_t popcnt(const void* data, uint64_t size) const uint64_t* ptr64 = (const uint64_t*)(ptr + i); cnt += popcnt_avx512(ptr64, (size - i) / 8); i = size - size % 8; - if (i == size) return cnt; - else - goto trailing_bytes; } #endif @@ -592,10 +589,6 @@ static inline uint64_t popcnt(const void* data, uint64_t size) } #endif -#if defined(LIBPOPCNT_HAVE_AVX512) - trailing_bytes: -#endif - #if defined(LIBPOPCNT_HAVE_POPCNT) /* * The user has compiled without -mpopcnt.