[Issue 21376] [x86-only] Returning 32-bit floats have wrong precision

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Nov 10 18:18:06 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=21376

--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject.org> ---
Assembly dump of return statement in `float abs()`

-----------------------------------------------------
dmd x86:
    call   hypotFeeZe
    add    $0x8,%esp
    leave
    ret    $0x8
-----------------------------------------------------
dmd x86_64:
    callq  hypotFeeZe
    add    $0x20,%rsp
    fstpl  -0x20(%rbp)
    movsd  -0x20(%rbp),%xmm0
    cvtsd2ss %xmm0,%xmm0
    leaveq
    retq
-----------------------------------------------------
gdc x86:
    call   hypotFeeZe
    add    $0x18,%esp
    fstps  -0x4(%ebp)
    flds   -0x4(%ebp)
    leave
    ret
-----------------------------------------------------
gdc x86_64:
    callq  hypotFeeZe
    add    $0x20,%rsp
    fstps  -0xc(%rbp)
    movss  -0xc(%rbp),%xmm0
    leaveq
    retq
-----------------------------------------------------

As expected, there is no fstp/fld generated by dmd x86, so the real value
returned by hypot is not truncated as per what x86_64 does.

--


More information about the Digitalmars-d-bugs mailing list