gdc or ldc for faster programs?

Siarhei Siamashka siarhei.siamashka at gmail.com
Wed Jan 26 18:39:07 UTC 2022


On Wednesday, 26 January 2022 at 18:00:41 UTC, Ali Çehreli wrote:
> ldc shines with sprintf. And dmd suprises by being a little bit 
> faster than gdc! (?)
>
> ldc (2.098.0): ~6.2 seconds
> dmd (2.098.1): ~7.4 seconds
> gdc (2.076.?): ~7.5 seconds
>
> Again, here are the versions of the compilers that are readily 
> available on my system:
>
> > ldc: LDC - the LLVM D compiler (1.28.0):
> >    based on DMD v2.098.0 and LLVM 13.0.0
> >
> > gdc: dc (GCC) 11.1.0 (Uses dmd 2.076 front end)

It's not DMD doing a good job here, but GDC11 shooting itself in 
the foot by requiring additional  esoteric command line options 
if you really want to produce optimized binaries. See 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102765 for more 
details.

You can try to re-run your benchmark after adding '-flto' or 
'-fno-weak-templates' to GDC command line. I see a ~7% speedup 
for your code on my computer.


More information about the Digitalmars-d-learn mailing list