From owner-svn-src-head@FreeBSD.ORG Thu Dec 4 16:55:42 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A7FF1845; Thu, 4 Dec 2014 16:55:42 +0000 (UTC) Received: from tensor.andric.com (tensor.andric.com [IPv6:2001:7b8:3a7:1:2d0:b7ff:fea0:8c26]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client CN "tensor.andric.com", Issuer "COMODO RSA Domain Validation Secure Server CA" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 55F13228; Thu, 4 Dec 2014 16:55:42 +0000 (UTC) Received: from [IPv6:2001:7b8:3a7::a188:410a:c650:9766] (unknown [IPv6:2001:7b8:3a7:0:a188:410a:c650:9766]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by tensor.andric.com (Postfix) with ESMTPSA id 65667B80A; Thu, 4 Dec 2014 17:55:38 +0100 (CET) Subject: Re: svn commit: r275468 - head/sys/dev/usb/controller Mime-Version: 1.0 (Mac OS X Mail 8.1 \(1993\)) Content-Type: multipart/signed; boundary="Apple-Mail=_C7AAA13C-9D6E-456B-A16A-501CF565AB43"; protocol="application/pgp-signature"; micalg=pgp-sha1 X-Pgp-Agent: GPGMail 2.5b3 From: Dimitry Andric In-Reply-To: <20141204005451.GM99957@funkthat.com> Date: Thu, 4 Dec 2014 17:55:40 +0100 Message-Id: <1373EB55-4238-40D0-B481-53C8B46D6E6C@FreeBSD.org> References: <201412032155.sB3LtjJN043364@svn.freebsd.org> <20141204005451.GM99957@funkthat.com> To: John-Mark Gurney X-Mailer: Apple Mail (2.1993) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Hans Petter Selasky X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Dec 2014 16:55:42 -0000 --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 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--