lkml.org 
[lkml]   [2003]   [Apr]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [RFC][PATCH] Faster generic_fls
From
Date
Linus Torvalds <torvalds@transmeta.com> writes:

> Yeah, except if you want best code generation you should probably use
>
> static inline int fls(int x)
> {
> int bit;
> /* Only well-defined for non-zero */
> asm("bsrl %1,%0":"=r" (bit):"rm" (x));

"g" should work for the second operand too and it'll give gcc
slightly more choices with possibly better code.

But the __builtin is probably preferable if gcc supports it because
a builtin can be scheduled, inline assembly can't.

-Andi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:35    [W:0.691 / U:0.140 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site