Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Aug 2015 10:03:27 +0800
From:      Erich Dollansky <erichsfreebsdlist@alogt.com>
To:        Hans Petter Selasky <hps@selasky.org>
Cc:        Andriy Gapon <avg@FreeBSD.org>, Konstantin Belousov <kostikbel@gmail.com>, "freebsd-hackers@freebsd.org" <freebsd-hackers@FreeBSD.org>
Subject:   Re: allow ffs & co. a binary search
Message-ID:  <20150811100327.0d12231f@X220.alogt.com>
In-Reply-To: <55C335A7.8020503@selasky.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> <55C335A7.8020503@selasky.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

On Thu, 06 Aug 2015 12:23:35 +0200
Hans Petter Selasky <hps@selasky.org> wrote:

> 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.
> >
> Has there been any further thoughts on this topic during the summer?
> 
I was just waiting for a clear result. I do not want to write something
which is not accepted at the end.

> 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.

Why not detect the built-in functions and do the binary search when
they are not available and leave the original implementation for all
other sizes?
> 
> 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?
> 
A clear route would be good. I could do it then.

Erich



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