Skip to content

Commit

Permalink
gust_g1t: fix incompatibility with non SSE4.2 platforms
Browse files Browse the repository at this point in the history
* Closes #8
  • Loading branch information
VitaSmith committed Jan 20, 2020
1 parent dc9c9e6 commit 386a952
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion util.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,12 @@ static __inline uint32_t find_msb(uint32_t v)
static __inline uint32_t popcount(uint32_t v)
{
#if defined (_MSC_VER)
return __popcnt(v);
// The built in __popcnt() used by Microsoft may require SSE4.2
// which not all machines have => use our own (GitHub issue #8).
v -= (v >> 1) & 0x55555555;
v = (v & 0x33333333) + ((v >> 2) & 0x33333333);
v = (v + (v >> 4)) & 0x0f0f0f0f;
return (v * 0x01010101) >> 24;
#else
return __builtin_popcount(v);
#endif
Expand Down

0 comments on commit 386a952

Please sign in to comment.