diff options
Diffstat (limited to 'src/compiler')
-rw-r--r-- | src/compiler/nir/nir_search_helpers.h | 13 | ||||
-rw-r--r-- | src/compiler/nir/nir_validate.c | 2 |
2 files changed, 5 insertions, 10 deletions
diff --git a/src/compiler/nir/nir_search_helpers.h b/src/compiler/nir/nir_search_helpers.h index 2d399bd5dcd..8bc6d723c34 100644 --- a/src/compiler/nir/nir_search_helpers.h +++ b/src/compiler/nir/nir_search_helpers.h @@ -28,12 +28,7 @@ #define _NIR_SEARCH_HELPERS_ #include "nir.h" - -static inline bool -__is_power_of_two(unsigned int x) -{ - return ((x != 0) && !(x & (x - 1))); -} +#include "util/bitscan.h" static inline bool is_pos_power_of_two(nir_alu_instr *instr, unsigned src, unsigned num_components, @@ -50,11 +45,11 @@ is_pos_power_of_two(nir_alu_instr *instr, unsigned src, unsigned num_components, case nir_type_int: if (val->i32[swizzle[i]] < 0) return false; - if (!__is_power_of_two(val->i32[swizzle[i]])) + if (!util_is_power_of_two_nonzero(val->i32[swizzle[i]])) return false; break; case nir_type_uint: - if (!__is_power_of_two(val->u32[swizzle[i]])) + if (!util_is_power_of_two_nonzero(val->u32[swizzle[i]])) return false; break; default: @@ -80,7 +75,7 @@ is_neg_power_of_two(nir_alu_instr *instr, unsigned src, unsigned num_components, case nir_type_int: if (val->i32[swizzle[i]] > 0) return false; - if (!__is_power_of_two(abs(val->i32[swizzle[i]]))) + if (!util_is_power_of_two_nonzero(abs(val->i32[swizzle[i]]))) return false; break; default: diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c index 725ba43152c..565cb2ef163 100644 --- a/src/compiler/nir/nir_validate.c +++ b/src/compiler/nir/nir_validate.c @@ -982,7 +982,7 @@ validate_var_decl(nir_variable *var, bool is_global, validate_state *state) validate_assert(state, is_global == nir_variable_is_global(var)); /* Must have exactly one mode set */ - validate_assert(state, util_bitcount(var->data.mode) == 1); + validate_assert(state, util_is_power_of_two_nonzero(var->data.mode)); if (var->data.compact) { /* The "compact" flag is only valid on arrays of scalars. */ |