summaryrefslogtreecommitdiffstats
path: root/src/compiler/nir/nir_search_helpers.h
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2017-11-13 13:00:53 -0800
committerIan Romanick <[email protected]>2018-03-29 14:09:28 -0700
commit22fbb5c5949b1590ef04b6432dd7f3a93a37c2ed (patch)
treec43dcd5e0d83802f39221369da90d1eed745b808 /src/compiler/nir/nir_search_helpers.h
parentd76c204d0564701b4b8b6a2bdda50e2939683e66 (diff)
util: Add and use util_is_power_of_two_nonzero
Signed-off-by: Ian Romanick <[email protected]> Reviewed-by: Eduardo Lima Mitev <[email protected]>
Diffstat (limited to 'src/compiler/nir/nir_search_helpers.h')
-rw-r--r--src/compiler/nir/nir_search_helpers.h13
1 files changed, 4 insertions, 9 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: