[PATCH xf86-video-ati] Calculate log base 2 in radeon.h based on clz for all platforms
Michel Dänzer
michel at daenzer.net
Mon Dec 5 02:22:13 UTC 2016
On 02/12/16 07:07 PM, Jochen Rollwagen wrote:
> 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).
> ---
> src/radeon.h | 13 +------------
> 1 file changed, 1 insertion(+), 12 deletions(-)
>
> diff --git a/src/radeon.h b/src/radeon.h
> index 5797bed..23ecfeb 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
Reviewed and pushed (with the superfluous parentheses removed and the
commit log line-wrapped at ~72 columns), thanks!
One request for future patches you want to be applied: Please put your
Signed-off-by: tag in the commit log.
--
Earthling Michel Dänzer | http://www.amd.com
Libre software enthusiast | Mesa and X developer
More information about the amd-gfx
mailing list