C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Modular integers

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Wed, 14 Jan 2026 12:52:02 -0500
On Wed, Jan 14, 2026 at 12:27 PM Hans Åberg via Std-Proposals
<std-proposals_at_[hidden]> wrote:
>
>
> > On 14 Jan 2026, at 18:13, David Brown <david.brown_at_[hidden]> wrote:
> >
> > On 14/01/2026 18:00, Hans Åberg via Std-Proposals wrote:
> >>> On 14 Jan 2026, at 16:34, Thiago Macieira via Std-Proposals <std-
> >>> proposals_at_[hidden]> 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.
> >
> > You are going around in circles here.
> >
> > First, neither GCC nor clang (nor, I believe, MSVC) are implemented in C - they are implemented in C++.
>
> It is the code here.
> https://github.com/llvm/llvm-project/blob/3424447645c0ae09cc97fc59fc0f2bd383a67ed1/compiler-rt/lib/builtins/udivmodti4.c
>
> > Secondly, the language used in the compiler is utterly irrelevant to the code it generates. And that generated code is in assembly, not C, C++, or any other HLL.
>
> It is the programming effort that is at issue here.
>
> > Thirdly, the language used is pretty much irrelevant to the algorithms used to generate the code. You personally might have found it convenient to work with recursive C++ templates - that does not hinder anyone from using recursive C functions to generate the same results.
>
> That would suffice if fully expanded at compile time.

... it's the compiler. *Everything it does* happens "at compile time".

Everything you say only makes sense if you think of the compiler as
some kind of translator. That the compiler is generating C code, which
some other process then converts into machine language for execution.
But that's just not the case.

If LLVM is not generating efficient code, that is not because it
cannot. It is not because it's written in C. It's not because
`_BitInt` is compatible with C. All of these things are completely
irrelevant.

LLVM is not generating efficiently code because it is not written to
do so at present. That's it. The compiler has 100% of the information
to generate efficient output, and it is completely capable of doing so
regardless of whether `_BitInt` is compatible with C. It simply is not
doing so at present.

Received on 2026-01-14 17:52:14