This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Add __builtin_clrsb, similar to clz/ctz
- From: Georg-Johann Lay <avr at gjlay dot de>
- To: Bernd Schmidt <bernds at codesourcery dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 16 Jun 2011 15:05:41 +0200
- Subject: Re: Add __builtin_clrsb, similar to clz/ctz
- References: <4DF9FA9A.8040505@codesourcery.com>
Bernd Schmidt schrieb:
> Several processors have a "count redundant sign bits" instruction:
>
> * SIGNBITS on Blackfin
> * NORM on C6X
> * SBC, apparently, on picochip
>
> and probably others. For example, for a value of 0 or -1, it returns 31,
> while e.g. an input 0xc0000000 produces 1.
>
> Other compilers tend to define builtin functions called "norm" for this,
> and the operation is used in some DSP benchmarks. The patch below adds a
> __builtin_clrsb family of functions, similar to __builtin_clz. I'm open
> to suggestions about the name; I don't particularly like "norm" but
> maybe that's what users expect.
Some call it cls "count leading signs". A clrxx reminds me rather of
"clear xx".
Johann
>
> Bernd
>