DMD backend quality (Was: Re: DIP 1031--Deprecate Brace-Style Struct Initializers--Community Review Round 1 Discussion)

H. S. Teoh hsteoh at quickfur.ath.cx
Sun Feb 16 00:16:24 UTC 2020


[Moving this to separate thread because it's tangential to DIP 1031
discussion.]

On Sat, Feb 15, 2020 at 03:59:39PM -0800, Walter Bright via Digitalmars-d wrote:
> On 2/15/2020 9:58 AM, jxel wrote:
> > how poor quality the backend code is.
> 
> Baloney.
> 
> It's written in an older style, sure, but it's remarkably bug free
> considering how complex it is. The complexity is a result of the
> fiendishly complex x86 instructions set.
> 
> The proof of its quality is it has successfully been extended from a
> purely 16 bit generator to 32 and extended again to 64 bit, and has
> been extended to support multiple ABIs and object file formats.
> 
> The DFA optimizer has also proven to be fast and very robust.

Unfortunately, the GDC and LDC optimizers consistently produce code that
outperforms code generated by the DMD backend by 20-30%, sometimes as
high as 40% for CPU-intensive code. DMD also tends to have more codegen
bugs when run with -O -inline (which, ironically, still produces
inferior code to what LDC/GDC produces with -O).

I'm sure, given enough time and effort, you could bring it to par, but
after >5 years of waiting, I've essentially given up on the DMD backend
for performance-sensitive code.  I now use LDC for my larger projects,
and would probably start new projects on LDC rather than DMD.

LDC can also cross-compile to Windows from Linux, which allows me the
very convenient setup of a single build script that builds both Linux
and Windows executables simultaneously.  With DMD I need a VM or at
least Wine (with its very slow and resource-intensive startup times) to
be able to do this. And LDC can target a *lot* more architectures than
x86 on Linux/Windows, such as WebAssembly, Android, etc.. Again, DMD
loses out here.

Of course, DMD is still very fast at compiling and useful for smaller
utilities and script-like programs where performance isn't critical, or
for running unittests for isolated modules during development due to
fast turnaround times. But codegen quality is definitely not among the
reasons I still use DMD.


T

-- 
Computers shouldn't beep through the keyhole.


More information about the Digitalmars-d mailing list