[Patch] Use __builtin_clz* for __lg
Joe Buck
Joe.Buck@synopsys.COM
Wed Oct 24 21:57:00 GMT 2007
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.
More information about the Libstdc++
mailing list