[lkml]   [2004]   [Jun]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: using gcc built-ins for bitops?
On Thu, Jun 24, 2004 at 02:31:09AM -0700, Paul Jackson wrote:
> I see a list of these gcc bitop builtins at the bottom of the page:
> Looks like you can find the position of the first 1 bit, the length of
> the leading or trailing seq of 0 bits, the hamming weight (popcount) and
> the parity, each for int, long and long long.
> I just add this for the benefit of others.
> As to your primary question - is this worth doing - I don't have
> an answer.

It is, for 2 reasons:
1) unlike __asm, GCC knows how to schedule the instructions in the builtins
2) GCC will handle stuff like ffz (16) at compile time rather than runtime

But, all the builtins are not natively supported on every architecture,
if there is no arch support, it falls back to a libgcc library function,
which the kernel probably wants to avoid.
E.g. popcount on i386, etc.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 14:04    [W:0.111 / U:2.576 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site