On 15 January 2014 12:22, David Nadlinger <code@klickverbot.at> wrote:
On Wednesday, 15 January 2014 at 01:42:07 UTC, Manu wrote:
Right, thanks for that.
I'm quite surprised by how bad that turned out actually, and with LDC,
which is usually the best at optimising that sort of thing.
Need to do some intensive experimentation... but this is a bit concerning.

GCC might do some loop merging, I haven't checked. It's just that this pattern doesn't tend to appear too much in traditional C/C++ code (after all, who splits up their loops into two parts just for fun?), so it could be that the LLVM people just never really bothered to write a pass to merge single loops that have been split (as opposed to classical loop fusion, where the loop ranges are the same, but the operations performed/target data different).

Maybe it would be possible to implement something like this fairly easily using the existing LLVM loop analyses though.

Okay. As long as the problem is understood and a solution seems realistic.
The closure allocation is also an important problem to fix, but that one's been on the list a long time.