[dmd-internals] 64 bit bug: rndtol fails.
Brad Roberts
braddr at puremagic.com
Tue Jan 18 01:20:05 PST 2011
On 1/12/2011 1:45 PM, Don Clugston wrote:
> ---
> import std.math;
>
> void main()
> {
> assert( rndtol(-3.0) == -3 );
> }
> ---
>
> This is the only failure in std.mathspecial.
Confirmed buggy in d1 as well.
The generated code:
_Dmain:
push RBP
mov RBP,RSP
sub RSP,010h
fld tbyte ptr FLAT:.rodata[00h][RIP]
fistp long64 ptr -8[RBP]
mov EAX,-8[RBP]
cmp RAX,0FFFFFFFDh
je L25
mov EDI,7
call _D3bug8__assertFiZv at PC32
L25: xor EAX,EAX
leave
ret
Comparing it with the 32 bit version, the tbyte ptr part is fine, but the mov
EAX is almost certainly wrong.
Try this change.. tested only with this repro case so far:
Index: backend/cg87.c
===================================================================
--- backend/cg87.c (revision 880)
+++ backend/cg87.c (working copy)
@@ -3063,7 +3063,11 @@
genfltreg(c2,0x8B,findreglsw(retregs),0);
}
else
+ {
c2 = genfltreg(c2,0x8B,reg,0); // MOV reg,floatreg
+ if (tysize(tym) == 8 && I64)
+ code_orrex(c2, REX_W);
+ }
c2 = cat(c2,fixresult(e,retregs,pretregs));
return cat(c1,c2);
More information about the dmd-internals
mailing list