* [PATCH xf86-video-ati] Calculate log base 2 in radeon.h based on clz for all platforms
@ 2016-12-02 10:07 Jochen Rollwagen
[not found] ` <584147C6.8000004-zqRNUXuvxA0b1SvskN2V4Q@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Jochen Rollwagen @ 2016-12-02 10:07 UTC (permalink / raw)
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
[-- Attachment #1: Type: text/plain, Size: 849 bytes --]
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
--
1.7.9.5
[-- Attachment #2: 0001-Calculate-log-base-2-in-radeon.h-based-on-clz-for-al.patch --]
[-- Type: text/x-patch, Size: 1054 bytes --]
>From 350d663a5ce85d51632a6fa56d28afa2447c6558 Mon Sep 17 00:00:00 2001
From: Jochen Rollwagen <joro-2013-zqRNUXuvxA0b1SvskN2V4Q@public.gmane.org>
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(-)
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
--
1.7.9.5
[-- Attachment #3: Type: text/plain, Size: 154 bytes --]
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH xf86-video-ati] Calculate log base 2 in radeon.h based on clz for all platforms
[not found] ` <584147C6.8000004-zqRNUXuvxA0b1SvskN2V4Q@public.gmane.org>
@ 2016-12-05 2:22 ` Michel Dänzer
0 siblings, 0 replies; 2+ messages in thread
From: Michel Dänzer @ 2016-12-05 2:22 UTC (permalink / raw)
To: Jochen Rollwagen; +Cc: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
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
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-05 2:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-02 10:07 [PATCH xf86-video-ati] Calculate log base 2 in radeon.h based on clz for all platforms Jochen Rollwagen
[not found] ` <584147C6.8000004-zqRNUXuvxA0b1SvskN2V4Q@public.gmane.org>
2016-12-05 2:22 ` Michel Dänzer
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.