This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [Patch] Use __builtin_clz* for __lg
- From: Joe Buck <Joe dot Buck at synopsys dot COM>
- To: Paolo Carlini <pcarlini at suse dot de>
- Cc: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 24 Oct 2007 14:57:43 -0700
- Subject: Re: [Patch] Use __builtin_clz* for __lg
- References: <471FA3AD.5010507@suse.de>
On Wed, Oct 24, 2007 at 09:57:33PM +0200, Paolo Carlini wrote:
> Hi,
>
> today, while working on something else, I noticed that we weren't
> exploiting the various __builtin_clz* for our internal integer log2.
> Seems a good idea to me, but please double check... Also, for the
> generic case, I'm seeing a slightly tighter loop with the below tweak
> (actually, that is apparently the most widespread way of implementing it).
>
> Tested x86_64-linux.
Your "specializations" aren't specializations, but ordinary functions.
I'm not sure whether this matters in practice, though.
That is, you define __lg(int), not __lg<int>(int).
I guess this might matter when __lg is called from a template. This
is an area of the standard that I am often a bit confused by, though.