This is the reverse of BITSET_FFS()
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4910>
return 0;
}
+/* Get the last bit set in a bitset.
+ */
+static inline int
+__bitset_last_bit(const BITSET_WORD *x, int n)
+{
+ for (int i = n - 1; i >= 0; i--) {
+ if (x[i])
+ return util_last_bit(x[i]) + BITSET_WORDBITS * i;
+ }
+
+ return 0;
+}
+
#define BITSET_FFS(x) __bitset_ffs(x, ARRAY_SIZE(x))
+#define BITSET_LAST_BIT(x, size) __bitset_last_bit(x, size)
static inline unsigned
__bitset_next_set(unsigned i, BITSET_WORD *tmp,