Disappointing math performance compared to GDC

David Nadlinger via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Wed Oct 8 10:50:19 PDT 2014


On Wednesday, 8 October 2014 at 16:26:02 UTC, Gabor Mezo wrote:
> Why those calls are not inlined?

They are likely in a different module than the code using them, 
right? Modules in D are supposed to be their own, separate 
compilation unit, just like .cpp in C++. Thus by default no 
inlining across module boundaries will take place, unless you use 
something like link-time optimization.

Now of course this is rather undesirable and a big problem for 
trivial helper functions. If you just compile a single 
executable, you can pass -singleobj to LDC to instruct it to 
generate only one object file, so that the optimization 
boundaries disappear (arguably, this should be the default).

Furthermore, both DMD and LDC actually attempt to work around 
this by also analyzing imported modules so that functions in them 
can be inlined. Unfortunately, the LDC implementation of this is 
defunct as of a couple of DMD frontend merges ago. Thus, not even 
simple cases as in your example are not covered. I'm working on a 
reimplementation right now, hopefully to appear in master soon.

Cheers,
David


More information about the digitalmars-d-ldc mailing list