svn commit: r275468 - head/sys/dev/usb/controller

Dimitry Andric dim at FreeBSD.org
Thu Dec 4 16:55:42 UTC 2014


On 04 Dec 2014, at 01:54, John-Mark Gurney <jmg at funkthat.com> wrote:
> 
> 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...

Maybe it is easier to alias ffs() and friends to __builtin_ffs(), since
the compilers we support have these builtins already.

-Dimitry

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 194 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/svn-src-all/attachments/20141204/04c7ee30/attachment.sig>


More information about the svn-src-all mailing list