diff options
author | Jochen Rollwagen <joro-2013@t-online.de> | 2016-12-02 10:56:39 +0100 |
---|---|---|
committer | Michel Dänzer <michel.daenzer@amd.com> | 2016-12-05 11:06:28 +0900 |
commit | a89c0bced423ce3e09f66edafc35642a7cc03b2f (patch) | |
tree | 58f9137bd82e3001eaabe7bb081fc5af89b27b58 /src | |
parent | e2942449171fe628a7726e59bcaab65e27d88563 (diff) |
Calculate log base 2 in radeon.h based on clz for all platforms
This commit replaces the inline assembler code (for x86 platforms) and
loop (for non-x86 platforms) in RADEONLog2 with a one-liner version
based on clz (count leading zeroes).
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/radeon.h | 13 |
1 files changed, 1 insertions, 12 deletions
diff --git a/src/radeon.h b/src/radeon.h index 5797beda..039a620b 100644 --- a/src/radeon.h +++ b/src/radeon.h @@ -935,18 +935,7 @@ enum { static __inline__ int RADEONLog2(int val) { - int bits; -#if (defined __i386__ || defined __x86_64__) && (defined __GNUC__) - __asm volatile("bsrl %1, %0" - : "=r" (bits) - : "c" (val) - ); - return bits; -#else - for (bits = 0; val != 0; val >>= 1, ++bits) - ; - return bits - 1; -#endif + return 31 - __builtin_clz(val); } #define RADEON_TILING_MASK 0xff |