A small comparison
jerro
a at a.com
Wed Nov 20 18:06:51 PST 2013
> void main() {
> import std.stdio, std.algorithm, std.range;
> enum n = 100;
> immutable double r = n.iota.map!(x => x.sin ^^
> 2).reduce!q{a + b};
> r.writeln;
> }
If I use core.stdc.math.sin and compile the code with:
gdc c.d -o c -O3 -fno-bounds-check -frelease
I get:
404e80: cvtsi2sd %ebx,%xmm0
404e84: callq 403070 <sin at plt>
404e89: mulsd %xmm0,%xmm0
404e8d: add $0x1,%ebx
404e90: cmp $0x64,%ebx
404e93: addsd 0x28(%rsp),%xmm0
404e99: movsd %xmm0,0x28(%rsp)
404e9f: jne 404e80 <_Dmain+0x60>
This is almost exactly the same code as
> .L3:
> cvtsi2sd %ebx, %xmm0
> call sin
> .L2:
> mulsd %xmm0, %xmm0
> addl $1, %ebx
> cmpl $100, %ebx
> addsd 8(%rsp), %xmm0
> movsd %xmm0, 8(%rsp)
> jne .L3
More information about the digitalmars-d-ldc
mailing list