Calculate log base 2 in radeon.h based on clz for all platforms
PATCH 1/1 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).
--- src/radeon.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
src/radeon.h +1 -12
@@ -935,18 +935,7 @@ enum {static __inline__int RADEONLog2 (int val) { -int bits; -#if (defined __i386__ || defined __x86_64__) && (defined __GNUC__) - __asmvolatile ("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
Signature · 1 line
1.7.9.5
Quoted 1 line
From
350d663a5ce85d51632a6fa56d28afa2447c6558Mon Sep 17 00:00:00 2001
From: Jochen Rollwagen <[email protected]>
Date: Fri, 2 Dec 2016 10:56:39 +0100
Subject: [PATCH] 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).
--- src/radeon.h | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
src/radeon.h +1 -12
@@ -935,18 +935,7 @@ enum {static __inline__int RADEONLog2 (int val) { -int bits; -#if (defined __i386__ || defined __x86_64__) && (defined __GNUC__) - __asmvolatile ("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
Signature · 1 line
1.7.9.5
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 21 lines · Jochen Rollwagen
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(-)src/radeon.h +0
-6@@ -935,18 +935,7 @@ enum {static __inline__int RADEONLog2 (int val) { -int bits; -#if (defined __i386__ || defined __x86_64__) && (defined __GNUC__) - __asmvolatile ("bsrl %1, %0" - :"=r" (bits) - :"c" (val) - );
src/radeon.h enum { · line 941
Quoted 10 lines
src/radeon.h +1
-6-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.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx