On 8/18/2015 2:57 PM, H. S. Teoh via Digitalmars-d wrote:
From the little that I've seen of dmd's output, it seems that it's
rather weak in the areas of inlining and loop unrolling / refactoring.

DMD does not do loop unrolling. I've thought about it many times, but just never did it.


In both cases, it seems that the optimizer gives up too quickly -- an
if-else function body will get inlined, but an if without an else
doesn't, etc..

It should do this. An example would be nice.


There's also the more general optimizations, like eliminating redundant
loads, eliding useless allocation of stack space in functions that
return constant values, etc.. While DMD does do some of this, it's not
as thorough as GDC. While it may sound like only a small difference, if
they happen to run inside an inner loop, they can add up to quite a
significant difference.

dmd has a full data flow analysis pass, which includes dead code elimination and dead store elimination. It goes as far as possible with the intermediate code. Any dead stores still generated are an artifact of the the detailed code generation, which I agree is a problem.


DMD needs to be much more aggressive in eliminating useless / redundant
code blocks; a lot of this comes not from people writing unusually
redundant code, but from template expansions and inlined range-based
code, which sometimes produce a lot of redundant operations if
translated directly.  Aggressively reducing these generated code blocks
will often open up further optimization opportunities.

I'm not aware of any case of DMD generating dead code blocks. I'd like to see it if you have one.

Reply via email to