Scorn:

> Hi bearophile. Thanks for your advice (i might try out ldc in the future
> but now i need phobos and not tango as standard library).

I like DMD for some of the D2 features, for its speed, for allowing exceptions 
to be used on Windows too, for its built-in profiler and code coverage analyser 
that are not present in LDC, and for other small things, but I like how LDC 
feels more like a real-world compiler, it has smaller features like 
force_inline that look like coming out of a more practical compiler.

When I optimize code on LDC, I see predictable improvements of the performance, 
while with DMD it's like a shoot in the dark, and I usually have to avoid 
several tweaks of the code, otherwise I get a negative improvement.


> But since all three dmd, ldc and gdc use the same frontend, the question
> from Trass3r still remains:
> Under which conditions are functions/methods inlined ?

I think LDC doesn't use the inliner of the front-end and just uses the much 
better inliner of the back-end. So the inling rules are probably all different 
(but in theory the front-end knows more about the D semantics, so LDC has to 
work even more to regain the lost semantics).

Those inling rules of C# are nice and tidy (despite it doesn't inline virtual 
methods, as Java HotSpot does. Aren't C# programmers complaining? C# 
programmers don't look obsessed with performance, this is often positive), but 
it's not easy to find them on most C/C++ compilers I know of. Have you ever 
seen the exact inlining rules of C code compiled with GCC 4.4.3?


> Do you know if ldc inlines functions/methods across modules ? (dmd
> doesn't seem to do it and neither does gdc).

I have just done a test, normally LDC is not able to inline across modules. 
This is a shitty situation.
But with LDC you can perform Link-Time Optimization too (but you have to ask 
for it!), that in my test I've just seen is able to inline across modules.


> And that is bad since for an actual project i have made a separate
> module with a lot of small utility math functions which should be
> inlined but don't because of this. When i inline them using mixins or
> manually i get an overall speed up of about 20%.

If you explain this problem to Walter he will surely tell you that such 
inlining can't be done because mumble mumble separate compilation mumble mumble 
was done fifteen years ago mumble mumble mumble (even if LDC is currently doing 
it) :-)

Good luck,
bearophile

Reply via email to