Date: Wed, 14 Jan 2026 18:45:54 +0100
Hi Hans,
On Wed, Jan 14, 2026 at 06:31:06PM +0100, Hans Ã…berg wrote:
> >>> What Hans has to show and has so far failed to do is that it would be
> >>> *impossible* for LLVM to match the performance of his code, providing a reason
> >>> why that would be the case.
> >>
> >> It looks difficult to do in C in the absence of templates, unlike C++
> >> then, because the code should be expanded statically for pipelining,
> >> even though there are suggestions in this thread that it might be possible.
> >
> > LLVM should be able to implement _BinInt() as a template if it would
> > make it more efficient. That's an implementation detail. The fact that
> > it's *currently* written in C doesn't prevent them from rewriting it in
> > C++, or in assembly.
>
> Indeed, it is a C compatibility type, intended to work exactly in C,
> which imposes some limitations. Discussions in the past focused on
> making a separate C++ type for bit interesting, which I think would be
> good.
Compatibility with C is not a problem.
- strchr(3) is a C function, and C++ implements it with an overload.
- countof() is an operator for C arrays, and gnulib implements it with
templates for C++.
<https://gitweb.git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/stdcountof.in.h;h=cf3fc1e560e900a23a2fc1123f2c2ca5016300b3;hb=HEAD>
Cheers,
Alex
On Wed, Jan 14, 2026 at 06:31:06PM +0100, Hans Ã…berg wrote:
> >>> What Hans has to show and has so far failed to do is that it would be
> >>> *impossible* for LLVM to match the performance of his code, providing a reason
> >>> why that would be the case.
> >>
> >> It looks difficult to do in C in the absence of templates, unlike C++
> >> then, because the code should be expanded statically for pipelining,
> >> even though there are suggestions in this thread that it might be possible.
> >
> > LLVM should be able to implement _BinInt() as a template if it would
> > make it more efficient. That's an implementation detail. The fact that
> > it's *currently* written in C doesn't prevent them from rewriting it in
> > C++, or in assembly.
>
> Indeed, it is a C compatibility type, intended to work exactly in C,
> which imposes some limitations. Discussions in the past focused on
> making a separate C++ type for bit interesting, which I think would be
> good.
Compatibility with C is not a problem.
- strchr(3) is a C function, and C++ implements it with an overload.
- countof() is an operator for C arrays, and gnulib implements it with
templates for C++.
<https://gitweb.git.savannah.gnu.org/gitweb/?p=gnulib.git;a=blob;f=lib/stdcountof.in.h;h=cf3fc1e560e900a23a2fc1123f2c2ca5016300b3;hb=HEAD>
Cheers,
Alex
-- <https://www.alejandro-colomar.es>
Received on 2026-01-14 17:46:02
