Date: Thu, 04 Dec 2014 21:37:14 +0100 From: Hans Petter Selasky <hps@selasky.org> To: John-Mark Gurney <jmg@funkthat.com> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r275468 - head/sys/dev/usb/controller Message-ID: <5480C5FA.4030402@selasky.org> In-Reply-To: <20141204175032.GQ99957@funkthat.com> References: <201412032155.sB3LtjJN043364@svn.freebsd.org> <20141204005451.GM99957@funkthat.com> <54800B60.9020208@selasky.org> <20141204175032.GQ99957@funkthat.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On 12/04/14 18:50, John-Mark Gurney wrote: > Hans Petter Selasky wrote this message on Thu, Dec 04, 2014 at 08:21 +0100: >> On 12/04/14 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... >>> >> >> Yes, I'm aware about that, but like you say it is not optimised for all >> platforms yet. So I'm not sure if it will give any benefit for the >> platform the driver is running on .... >> >> I'll see if I can change the logic inside the C-version of ffs() and the >> do the swap like you suggest. > > Did you see the comment about usig __builtin_ffs{,l,ll} instead? this > seems to be a better route... > Hi, I see. Who can update the cpufunc.h header file to use the builtins? Are these also available with GCC? --HPS
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?5480C5FA.4030402>