diff --git a/src/port/pg_bitutils.c b/src/port/pg_bitutils.c
index 97bfcebe4e1..e0198f3ab35 100644
--- a/src/port/pg_bitutils.c
+++ b/src/port/pg_bitutils.c
@@ -90,9 +90,11 @@ pg_popcount_available(void)
 static int
 pg_popcount32_choose(uint32 word)
 {
+#if defined(HAVE__GET_CPUID) || defined(HAVE__CPUID)
 	if (pg_popcount_available())
 		pg_popcount32 = pg_popcount32_hw;
 	else
+#endif
 		pg_popcount32 = pg_popcount32_builtin;
 
 	return pg_popcount32(word);
@@ -178,9 +180,11 @@ pg_popcount(const char *buf, int bytes)
 static int
 pg_popcount64_choose(uint64 word)
 {
+#if defined(HAVE__GET_CPUID) || defined(HAVE__CPUID)
 	if (pg_popcount_available())
 		pg_popcount64 = pg_popcount64_hw;
 	else
+#endif
 		pg_popcount64 = pg_popcount64_builtin;
 
 	return pg_popcount64(word);
