Skip to content

Commit

Permalink
Add AVX512 trailing bytes optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
kimwalisch committed Jun 26, 2024
1 parent 8fdabaa commit adf413a
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libpopcnt.h
Original file line number Diff line number Diff line change
Expand Up @@ -553,8 +553,11 @@ 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

Expand All @@ -573,6 +576,10 @@ 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.
Expand Down

0 comments on commit adf413a

Please sign in to comment.