This will be needed by radeonsi.
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
#endif
}
+/**
+ * Find last bit set in a word. The least significant bit is 1.
+ * Return 0 if no bits are set.
+ */
+static INLINE unsigned
+util_last_bit64(uint64_t u)
+{
+#if defined(HAVE___BUILTIN_CLZLL)
+ return u == 0 ? 0 : 64 - __builtin_clzll(u);
+#else
+ unsigned r = 0;
+ while (u) {
+ r++;
+ u >>= 1;
+ }
+ return r;
+#endif
+}
+
/**
* Find last bit in a word that does not match the sign bit. The least
* significant bit is 1.