allow ffs & co. a binary search
Erich Dollansky
erichsfreebsdlist at alogt.com
Tue Aug 11 02:03:37 UTC 2015
Hi,
On Thu, 06 Aug 2015 12:23:35 +0200
Hans Petter Selasky <hps at 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
More information about the freebsd-hackers
mailing list