When will you implement cent and ucent?

max haughton maxhaton at gmail.com
Tue Mar 29 12:20:21 UTC 2022


On Tuesday, 29 March 2022 at 12:06:54 UTC, deadalnix wrote:
> On Tuesday, 29 March 2022 at 06:28:17 UTC, Era Scarecrow wrote:
>>[...]
>
> 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.

I agree. Having dmd as a fast backend is OK but if something as 
basically trivial as this cannot be implemented the we are in 
trouble.

That being said it may be possible to lower the cent type to the 
druntime type as a hack, then LDC and GDC can do what they need 
to do.


More information about the Digitalmars-d mailing list