A small comparison
bearophile
bearophileHUGS at lycos.com
Thu Nov 21 03:01:47 PST 2013
jerro:
> 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
I guess the back-end is very similar, and it's able to optimize
the code well :-)
What's the difference between std.math.sin and core.stdc.math.sin?
Bye,
bearophile
More information about the digitalmars-d-ldc
mailing list