X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvppinfra%2Fbitops.h;h=17ad49ffb46adc25c8ab14a24f4524e8719f28e8;hb=e759bb543c38a682dc31492a3a0a58669a811538;hp=ab91b8ae443ae8d84b9b9a8eb8066e9f0875c5e0;hpb=7cd468a3d7dee7d6c92f69a0bb7061ae208ec727;p=vpp.git diff --git a/src/vppinfra/bitops.h b/src/vppinfra/bitops.h index ab91b8ae443..17ad49ffb46 100644 --- a/src/vppinfra/bitops.h +++ b/src/vppinfra/bitops.h @@ -44,6 +44,13 @@ always_inline uword count_set_bits (uword x) { +#ifdef __POPCNT__ +#if uword_bits == 64 + return __builtin_popcountll (x); +#else + return __builtin_popcount (x); +#endif +#else #if uword_bits == 64 const uword c1 = 0x5555555555555555; const uword c2 = 0x3333333333333333; @@ -71,6 +78,7 @@ count_set_bits (uword x) #endif return x & (2 * BITS (uword) - 1); +#endif } /* Based on "Hacker's Delight" code from GLS. */