[Mesa-dev] [PATCH 05/10] nir: Use well-known power-of-two test instead of util_bitscan
Ian Romanick
idr at freedesktop.org
Fri Nov 10 22:32:45 UTC 2017
From: Ian Romanick <ian.d.romanick at intel.com>
This prevents the next change from breaking the build, and I felt that
it was different enough from the rest of that patch to stand on its own.
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/compiler/nir/nir_validate.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/compiler/nir/nir_validate.c b/src/compiler/nir/nir_validate.c
index 9bf8c70..ca191d2 100644
--- a/src/compiler/nir/nir_validate.c
+++ b/src/compiler/nir/nir_validate.c
@@ -979,8 +979,9 @@ 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);
+ /* Must have exactly one mode set (i.e., is a power of two) */
+ validate_assert(state, (var->data.mode != 0 &&
+ !(var->data.mode & (var->data.mode - 1))));
if (var->data.compact) {
/* The "compact" flag is only valid on arrays of scalars. */
--
2.9.5
More information about the mesa-dev
mailing list