On Sunday, 3 August 2014 at 22:24:22 UTC, safety0ff wrote:
On Sunday, 3 August 2014 at 19:52:42 UTC, Philippe Sigaud wrote:

Can someone confirm the results and tell me what I'm doing wrong?

LDC is likely optimizing the summation:

    int sum = 0;
    foreach(i; 0..task.goal)
        sum += i;

To something like:

    int sum = cast(int)(cast(ulong)(task.goal-1)*task.goal/2);

This is correct – the LLVM optimizer indeed gets rid of the loop completely.

Although I'd be more than happy to be able to claim a thousandfold speedup over DMD on real-world applications. ;)

Cheers,
David

Reply via email to