From 0b6c463dac4a25c927f419e65023979cc45ce60d Mon Sep 17 00:00:00 2001 From: Bas Nieuwenhuizen Date: Wed, 13 Apr 2016 23:30:55 +0200 Subject: [PATCH] gallium/util: Add u_bit_scan_consecutive_range64. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit For use by radeonsi. v2: Make sure that it works for all 64 bits set. Signed-off-by: Bas Nieuwenhuizen Reviewed-by: Marek Olšák --- src/gallium/auxiliary/util/u_math.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h index d983af33203..10f158b7086 100644 --- a/src/gallium/auxiliary/util/u_math.h +++ b/src/gallium/auxiliary/util/u_math.h @@ -529,6 +529,20 @@ u_bit_scan_consecutive_range(unsigned *mask, int *start, int *count) *mask &= ~(((1u << *count) - 1) << *start); } +static inline void +u_bit_scan_consecutive_range64(uint64_t *mask, int *start, int *count) +{ + if (*mask == ~0llu) { + *start = 0; + *count = 64; + *mask = 0; + return; + } + *start = ffsll(*mask) - 1; + *count = ffsll(~(*mask >> *start)) - 1; + *mask &= ~(((1llu << *count) - 1) << *start); +} + /** * Return float bits. */ -- 2.30.2