Using shorthand *= leads to unexpected result?
Saurabh Das via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun May 15 06:47:28 PDT 2016
On Sunday, 15 May 2016 at 13:25:42 UTC, Michael wrote:
> Well I'm pretty sure the code was working just fine earlier in
> the week at the office, but running the code at home with the
> newest version of DMD started producing these odd results.
Typing this function into asm.dlang.org shows a minor difference
in the assembly generated:
auto f1(double d1)
{
d1 *= -1.0;
return d1;
}
With DMD 2.070.2:
pure nothrow @nogc @safe double example.f1(double):
push %rbp
mov %rsp,%rbp
sub $0x10,%rsp
movsd %xmm0,-0x8(%rbp)
xorb $0x80,-0x1(%rbp)
rex.W movsd -0x8(%rbp),%xmm0
leaveq
retq
nopl 0x0(%rax)
With DMD 2.071.0:
pure nothrow @nogc @safe double example.f1(double):
push %rbp
mov %rsp,%rbp
sub $0x10,%rsp
movsd %xmm0,-0x8(%rbp)
xorb $0x80,-0x8(%rbp)
rex.W movsd -0x8(%rbp),%xmm0
leaveq
retq
nopl 0x0(%rax)
The xorb line is different and I conjecture that it is causing
the bug. I have never used floating-point assembly instructions,
so I cannot understand what the logic is here. I'll read up and
try to interpret to confirm.
Hope this helps.
More information about the Digitalmars-d-learn
mailing list