Comment #3 by ilyayaroshenko — 2014-09-17T08:21:57Z
No, (In reply to Iain Buclaw from comment #2)
> FYI, this looks more like an x87 problem, rather than compiler. And it's
> not just D that is affected by this.
>
> For instance, this bug in gcc:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
>
>
> Though they did eventually fix it in implementing C99-conformant (kinda)
> excess precision.
>
> http://marc.info/?l=gcc-patches&m=122576450613005&w=2
I have looked into disassembler code.
It is Not problem with x87
0. dmd do this optimization
d+=d and c}
1. float and double on 64bit are using xmm registers even in dmd.
2. It works fine with LDC.
Comment #4 by ilyayaroshenko — 2014-09-17T08:25:55Z
No, (In reply to Iain Buclaw from comment #2)
> FYI, this looks more like an x87 problem, rather than compiler. And it's
> not just D that is affected by this.
>
> For instance, this bug in gcc:
>
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=323
>
>
> Though they did eventually fix it in implementing C99-conformant (kinda)
> excess precision.
>
> http://marc.info/?l=gcc-patches&m=122576450613005&w=2
I am sorry for previous not finished comment.
I have looked into disassembler code.
It is Not problem with x87
0. dmd do this optimization
{d+=d; c+=d}
But this is correct only when flags like -ffast-math was enabled.
1. float and double on 64bit are using xmm registers even in dmd.
2. It works fine with LDC.
Comment #5 by ilyayaroshenko — 2014-09-17T08:41:49Z
For example current std.math.log implementation (from CEPHES library if I am not wrong) needs IEEE754 standard.
If there are bugs like current then log function can be incorrect.
log2 contains code:
z = x - 0.5;
z -= 0.5;
This should not be optimized.
Am sorry for my English.
Comment #6 by ibuclaw — 2014-09-17T12:18:09Z
(In reply to Илья Ярошенко from comment #5)
> For example current std.math.log implementation (from CEPHES library if I am
> not wrong) needs IEEE754 standard.
>
> If there are bugs like current then log function can be incorrect.
>
> log2 contains code:
>
> z = x - 0.5;
> z -= 0.5;
>
> This should not be optimized.
>
DMD does this:
return yl2x(x, LN2);
Which translates to:
fyl2x ST1(x), ST(LN2)
Comment #7 by ilyayaroshenko — 2014-09-17T12:40:42Z