util: move pot functions to use existing macros

Signed-off-by: Rohan Garg <rohan.garg@intel.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20153>
This commit is contained in:
Rohan Garg
2022-12-15 17:52:20 +01:00
committed by Marge Bot
parent f4f133ab37
commit 0539dec10f

View File

@@ -42,6 +42,8 @@
#include <popcntintrin.h>
#endif
#include "macros.h"
#ifdef __cplusplus
extern "C" {
#endif
@@ -128,7 +130,7 @@ u_bit_scan64(uint64_t *mask)
static inline bool
util_is_power_of_two_or_zero(unsigned v)
{
return (v & (v - 1)) == 0;
return IS_POT(v);
}
/* Determine if an uint64_t value is a power of two.
@@ -139,7 +141,7 @@ util_is_power_of_two_or_zero(unsigned v)
static inline bool
util_is_power_of_two_or_zero64(uint64_t v)
{
return (v & (v - 1)) == 0;
return IS_POT(v);
}
/* Determine if an unsigned value is a power of two.
@@ -162,7 +164,7 @@ util_is_power_of_two_nonzero(unsigned v)
#ifdef __POPCNT__
return _mm_popcnt_u32(v) == 1;
#else
return v != 0 && (v & (v - 1)) == 0;
return v != 0 && IS_POT(v);
#endif
}