DMD2 vs LDC2 inliner

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Feb 25 04:08:38 UTC 2019


On Sunday, February 24, 2019 7:49:36 PM MST James Blachly via Digitalmars-d-
learn wrote:
> Any ideas why DMD2 cannot inline this, but LDC2 has no problem doing so
> -- or suggestions for what I can do to make DMD2 inline it?

The unfortunate reality of the matter is that dmd's inliner is very poor,
and while dmd's optimizer is decent in general, llvm has had way more work
into improving its optimizer in recent years, so ldc is just plain going to
be better at optimizing code. dmd will do a decent job optimizing code, but
if you really care about your code being optimized, you need to use ldc or
gdc. And the gap there is likely to get larger over time, not smaller,
because relatively little work is put into dmd's backend. Given that dmd's
backend has now been ported to D, we may see more work being done on it, but
I expect that most of the effort will still go to the front-end, and llvm
and gcc simply have far more folks working on them, so aside from
optimizations that are D-specific, their backends are more likely to see
improvement than dmd's backend is.

One issue that's commonly brought up about dmd's inliner is that it's in the
front-end, which apparently is a poor way to do inlining. One side effect of
that though would be that unless the ldc folks go to extra effort to disable
the front-end's inliner, ldc has that inliner - and then it's inlining using
llvm. So, given that, it's practically guaranteed to do a better job.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list