Date: Thu, 4 Dec 2014 17:55:40 +0100 From: Dimitry Andric <dim@FreeBSD.org> To: John-Mark Gurney <jmg@funkthat.com> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Hans Petter Selasky <hselasky@freebsd.org> Subject: Re: svn commit: r275468 - head/sys/dev/usb/controller Message-ID: <1373EB55-4238-40D0-B481-53C8B46D6E6C@FreeBSD.org> In-Reply-To: <20141204005451.GM99957@funkthat.com> References: <201412032155.sB3LtjJN043364@svn.freebsd.org> <20141204005451.GM99957@funkthat.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_C7AAA13C-9D6E-456B-A16A-501CF565AB43 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii On 04 Dec 2014, at 01:54, John-Mark Gurney <jmg@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 --Apple-Mail=_C7AAA13C-9D6E-456B-A16A-501CF565AB43 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.26 iEYEARECAAYFAlSAkgwACgkQsF6jCi4glqOGZACfVMhO4rmt//CSiX0+VASE70+K 9FkAoPn5PRfsUsn7QPATxijWI58US3BE =SYnJ -----END PGP SIGNATURE----- --Apple-Mail=_C7AAA13C-9D6E-456B-A16A-501CF565AB43--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1373EB55-4238-40D0-B481-53C8B46D6E6C>