When will you implement cent and ucent?

deadalnix deadalnix at gmail.com
Tue Mar 29 12:06:54 UTC 2022


On Tuesday, 29 March 2022 at 06:28:17 UTC, Era Scarecrow wrote:
> On Monday, 28 March 2022 at 19:35:10 UTC, deadalnix wrote:
>> Why do I even have to argue that case?
>
>  Because different architectures and compilers do different 
> things. And some people value correctness over speed, 
> especially if later we do get 128bit registers we want it to 
> work exactly as expected when it gets recompiled.
>

No, I picked the exact same toolchain on purpose so that the 
approach themselves can be compared.

There is no correctness vs speed here, both code are correct. One 
is going to be significantly faster, but, in addition, one is 
going to optimize better with it surroundings, so what you'll see 
in practice is an even wider gap that what is presented above.

This approach will not work. I know because I specifically worked 
on making LLVM optimize this type of code and know how much 
harder it is to get good code in the presence of 128 bits 
integers vs in their absence.

The CPU has a lot of instructions to help handle large integers. 
When you let the backend do its magic, it can leverage them. When 
you instead give it good old small integers code and it has to 
infer the meaning from it and reconstruct the large integers ops 
you meant to be doing and optmize that, you introduce so many 
failure point that it's practically impossible to get a 
competitive result.

Once again, both of the exemple above you *THE EXACT SAME* 
toolchain, the only different is the approach to 128 bits 
integers in the frontend.


More information about the Digitalmars-d mailing list