Hi, FWIW the following routine is consistently slightly faster using Steven's test harness , with a big win when no bit set.
static inline int new_find_first_bit(const unsigned long *b, unsigned size) { int x = 0; do { unsigned long v = *b++; if (v) return __ffs(v) + x; if (x >= size) break; x += 32; } while (1); return x; } Tested on P III M 933MHz / gcc 4.0.1 clock speed = 00000000:17c56980 398813568 ticks per second no bit set ffb=320 my=320 new=320 generic ffb: 00000000:02fd6660 time: 0.125776182us my ffb: 00000000:03c314e9 time: 0.158260714us new ffb : 00000000:02d9190b time: 0.119810758us last bit set ffb=319 my=319 new=319 generic ffb: 00000000:04e5900c time: 0.205994717us my ffb: 00000000:0327475d time: 0.132658024us new ffb: 00000000:02c86938 time: 0.117068655us middle bit set ffb=159 my=159 new=159 generic ffb: 00000000:03c2bc56 time: 0.158203865us my ffb: 00000000:01356b8b time: 0.050846204us new ffb: 00000000:0115f133 time: 0.045673521us first bit set ffb=0 my=0 new=0 generic ffb: 00000000:02d07460 time: 0.118390436us my ffb: 00000000:005d3079 time: 0.015313564us new ffb: 00000000:005cca07 time: 0.015247804us Cheers Richard Not subscribed please CC -- thanks. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/