Date: Wed, 14 Jan 2026 18:27:17 +0100
> 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.
> You have written some 30 or 40 posts while failing to answer the critical questions here. Until you do, this discussion is going nowhere.
>
> 1. Is there any fundamental reason why a compiler implementation of _BitInt cannot generate at least as fast code as you can do with your templates? We don't care (at this stage) about what current compilers actually /do/, or how much effort it would be to make them generate as good code as you have.
It can if padded to the nearest 2^⁽2^k) word.
> 2. Assuming compilers can implement _BitInt operations as efficiently as you like, is there any other reason to have large modular integers in the C++ library?
Modular integers are not bit integers if the modulus is not a power of 2.
>
> 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.
> You have written some 30 or 40 posts while failing to answer the critical questions here. Until you do, this discussion is going nowhere.
>
> 1. Is there any fundamental reason why a compiler implementation of _BitInt cannot generate at least as fast code as you can do with your templates? We don't care (at this stage) about what current compilers actually /do/, or how much effort it would be to make them generate as good code as you have.
It can if padded to the nearest 2^⁽2^k) word.
> 2. Assuming compilers can implement _BitInt operations as efficiently as you like, is there any other reason to have large modular integers in the C++ library?
Modular integers are not bit integers if the modulus is not a power of 2.
Received on 2026-01-14 17:27:38
