diff --git a/src/port/pg_bitutils.c b/src/port/pg_bitutils.c index 97422e05040..fe6afb9fba5 100644 --- a/src/port/pg_bitutils.c +++ b/src/port/pg_bitutils.c @@ -299,7 +299,14 @@ pg_popcount64_choose(uint64 word) static int pg_popcount64_sse42(uint64 word) { +#if defined(HAVE_LONG_INT_64) return __builtin_popcountl(word); +#elif defined(HAVE_LONG_LONG_INT_64) + return __builtin_popcountll(word); +#else + /* shouldn't happen */ +#error must have a working 64-bit integer datatype +#endif } #endif @@ -407,7 +414,14 @@ pg_rightmost_one64_choose(uint64 word) static int pg_rightmost_one64_abm(uint64 word) { +#if defined(HAVE_LONG_INT_64) return __builtin_ctzl(word); +#elif defined(HAVE_LONG_LONG_INT_64) + return __builtin_ctzll(word); +#else + /* shouldn't happen */ +#error must have a working 64-bit integer datatype +#endif } #endif @@ -493,7 +507,15 @@ pg_leftmost_one64_choose(uint64 word) static int pg_leftmost_one64_abm(uint64 word) { +#if defined(HAVE_LONG_INT_64) return 63 - __builtin_clzl(word); +#elif defined(HAVE_LONG_LONG_INT_64) + return 63 - __builtin_clzll(word); +#else + /* shouldn't happen */ +#error must have a working 64-bit integer datatype +#endif + } #endif