Hans Petter Selasky wrote this message on Wed, Dec 03, 2014 at 21:55 +0000:
> Author: hselasky
> Date: Wed Dec  3 21:55:44 2014
> New Revision: 275468
> URL: https://svnweb.freebsd.org/changeset/base/275468
> 
> Log:
>   Optimise the bit searching loops, by quickly skipping the 16 first set
>   bits if all the 16 first bits are set. This way the worst case
>   searching time is reduced from 32 to 16 cycles.

You could use ffs instead:
        x = ffs(~map);
        if (x) {
                x--;
                /* normal code */
        }

This has the benefit of using a single instruction on platforms that
support it (bsfl on i386), though apparently, we haven't optimized this
for all platforms...  arm has a version for int, but their ffsl does
the same linear search instead of just calling ffs, or at least
detecting if sizeof(long) == sizeof(int) and calling ffs...

-- 
  John-Mark Gurney                              Voice: +1 415 225 5579

     "All that I will do, has been done, All that I have, has not."
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to