replace _mesa_is_pow_two with util_is_power_of_two_*

Mostly this uses util_is_power_of_two_or_zero, which has the same
behavior as _mesa_is_pow_two when the input is zero. In cases where the
value is known to be != 0 ahead of time I used the _nonzero variant as
it may be faster on some platforms.

Reviewed-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3024>
This commit is contained in:
Dylan Baker
2018-09-06 11:36:19 -07:00
parent c1e7c1f422
commit e533fad182
11 changed files with 29 additions and 40 deletions

View File

@@ -986,7 +986,7 @@ static inline struct brw_reg
spread(struct brw_reg reg, unsigned s)
{
if (s) {
assert(_mesa_is_pow_two(s));
assert(util_is_power_of_two_nonzero(s));
if (reg.hstride)
reg.hstride += cvt(s) - 1;

View File

@@ -2064,8 +2064,7 @@ generate_code(struct brw_codegen *p,
*
* where they pack the four bytes from the low and high four DW.
*/
assert(_mesa_is_pow_two(dst.writemask) &&
dst.writemask != 0);
assert(util_is_power_of_two_nonzero(dst.writemask));
unsigned offset = __builtin_ctz(dst.writemask);
dst.type = BRW_REGISTER_TYPE_UB;