sin, cos, other languages and DMD/LDC difference
Walter Bright
newshound2 at digitalmars.com
Sat Feb 8 12:52:27 PST 2014
On 2/8/2014 6:13 AM, bearophile wrote:
> Philippe Sigaud:
>
>> Now, what I found more confusing is that, compiling with DMD or LDC, I got
>> different results. Since Phobos code defining sin and cos in std.math and
>> core.stdc.math is the same for DMD and LDC (duh!), I guess that means
>> different intrinsics are used?
>
> LDC2 optimizes this code even worse than DMD.
Even worse? Mind telling me what is bad about this code?
fld qword ptr 4[ESP]
fmul qword ptr FLAT:_DATA[00h]
fsin
fld qword ptr 4[ESP]
fmul qword ptr FLAT:_DATA[08h]
fcos
faddp ST(1),ST
ret 8
BTW, the differences in results is not due to optimization, but to dmd keeping
intermediate results to 80 bits of precision, while other compilers are doing 64
bit precision on intermediate results.
More information about the Digitalmars-d
mailing list