Re: [RFC][PATCH] Faster generic_fls

From: Daniel Phillips (dphillips@sistina.com)
Date: Thu May 01 2003 - 19:13:41 EST


On Friday 02 May 2003 01:27, Thomas Schlichter wrote:
> ...So for me the table version seems to be the slowest one. The BSRL
> instruction on the K6-III seems to be very slow, too. The tree and my shift
> version are faster than the original version here...
>
> That someone else can test my fls_shift version I'll provide it here again:
> static inline int fls_shift(int x)
> {
> int bit = 32;
>
> while(x > 0) {
> --bit;
> x <<= 1;
> }
>
> return x ? bit : 0;
> }

Your shift version is the fastest on the PIII as well, finishing in 45.3
seconds vs 53.4 for my original, and using only 12 bytes of text. This was a
big surprise. The time was the same, whether I inlined it or not. I take
this to mean that -O3 inlines such a short function in either case.

Regards,

Daniel
-
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/



This archive was generated by hypermail 2b29 : Wed May 07 2003 - 22:00:14 EST