aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/gallium/auxiliary/util/u_math.h
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/gallium/auxiliary/util/u_math.h')
-rw-r--r--mesalib/src/gallium/auxiliary/util/u_math.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/mesalib/src/gallium/auxiliary/util/u_math.h b/mesalib/src/gallium/auxiliary/util/u_math.h
index 4047bd9b0..607fbecb0 100644
--- a/mesalib/src/gallium/auxiliary/util/u_math.h
+++ b/mesalib/src/gallium/auxiliary/util/u_math.h
@@ -482,12 +482,16 @@ unsigned ffs( unsigned u )
*/
static INLINE unsigned util_last_bit(unsigned u)
{
+#if defined(__GNUC__) && ((__GNUC__ * 100 + __GNUC_MINOR__) >= 304)
+ return u == 0 ? 0 : 32 - __builtin_clz(u);
+#else
unsigned r = 0;
while (u) {
r++;
u >>= 1;
}
return r;
+#endif
}