util: move pot functions to use existing macros
authorRohan Garg <rohan.garg@intel.com>
Thu, 15 Dec 2022 16:52:20 +0000 (17:52 +0100)
committerMarge Bot <emma+marge@anholt.net>
Thu, 25 May 2023 21:24:45 +0000 (21:24 +0000)
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>

src/util/bitscan.h

index 53cbb91..0e7019a 100644 (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
 }