Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 06 Aug 2015 12:23:35 +0200
From:      Hans Petter Selasky <hps@selasky.org>
To:        Andriy Gapon <avg@FreeBSD.org>, Konstantin Belousov <kostikbel@gmail.com>
Cc:        "freebsd-hackers@freebsd.org" <freebsd-hackers@FreeBSD.org>,  Erich Dollansky <erichsfreebsdlist@alogt.com>
Subject:   Re: allow ffs & co. a binary search
Message-ID:  <55C335A7.8020503@selasky.org>
In-Reply-To: <5582CCF1.8010505@FreeBSD.org>
References:  <20150607081315.7c0f09fb@B85M-HD3-0.alogt.com> <5573EA5E.40806@selasky.org> <20150607195245.62dc191f@B85M-HD3-0.alogt.com> <20150607135453.GH2499@kib.kiev.ua> <558175FA.4040106@FreeBSD.org> <20150617165331.GA2080@kib.kiev.ua> <5582CCF1.8010505@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On 06/18/15 15:51, Andriy Gapon wrote:
> On 17/06/2015 19:53, Konstantin Belousov wrote:
>> AFAIR it was about 'sufficiently smart compiler' and the fact that the
>> functions are not on the hottest paths.
>
> It seems that sufficiently smart compilers still do not exist :-)
> At least as far as compilers that are used for compiling FreeBSD are considered.
>
> [Offtopic] my impression is that lately smartness of compilers is mostly being
> improved by various tricks and shortcuts (undefined behavior, etc), rather than
> by recognizing patterns in the C code that could be turned into more efficient
> machine code.
>

Hi,

Has there been any further thoughts on this topic during the summer?

It sounds fair to me that "Sean Eron Anderson's Bit Twiddling Hacks" can 
be used in our code instead of a for() loop for the ffs() function, 
given that a 2-clause BSD license is fine by Sean. Typically the 
compilers can expand for loops using -O3, but I've never seen a compiler 
yet that convert for loops into a simpler functions where no constants 
are involved.

For sake of readability I would leave the old implementation under "#if 
0" so that readers not familiar with binary tricks can understand the code.

Any strong objections?

--HPS



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?55C335A7.8020503>