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
On Mer, 2003-04-30 at 22:59, Falk Hueffner wrote:
> > ffs(x^(x-1)) == fls(x)
>
> I don't think so. Maybe you are thinking of ffs(x) == fls(x & -x). So
> you can calculate ffs with fls, but not easily the other way round.

Well I asked my CPU to double check. If I got the code right it thinks that
ffs(i^(i-1))==fls(i) is true for 1->2^32-1

If you think about it it seems to make sense

x-1 turns the lowest 100..0 sequence into 01......1

The xor removes unchanged higher bits

so
10100
-1 10011
XOR 00111


-
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.081 / U:0.892 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site