https://issues.dlang.org/show_bug.cgi?id=18671
Issue ID: 18671 Summary: Implement loop unrolling in dmd's optimizer Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: enhancement Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: hst...@quickfur.ath.cx It has been known for a while that dmd's optimizer tends to lag behind gdc/ldc's when it comes to the performance of the generated code. While this may give the appearance of general poor quality of the optimizer, closer inspection reveals that actually dmd's optimizer does perform many standard optimization operations, and arguably pretty well at it (it even performs code hoisting from loops, for example). One big reason it fails to generate code with performance competitive with ldc/gdc is because, as Walter himself said, it doesn't unroll loops. When it comes to optimization, there is often a domino effect where one optimization leads to opportunities for further optimizations, whereas if that first optimization wasn't performed, it also closes the door to subsequent optimizations. Loops being generally the locus of most performance-sensitive code means that loop optimizations are especially sensitive to this effect, and loop unrolling is an important step that could often lead to further optimization opportunities. Missing this step is a big reason why dmd's optimizer often doesn't produce competitive code over ldc/gdc. This has been talked about often, but it's about time it's logged as a real request so that it won't be forgotten (and, one hopes, the chances of it actually being implemented might increase just a tad further away from zero). tl;dr: please implement loop unrolling in dmd. ;-) --