www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21835] New: Operation on float should use XMM register, not x87

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

          Issue ID: 21835
           Summary: Operation on float should use XMM register, not x87
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

Code:

void test()
{
    Point p;
    if (p.f != 0.0) assert(0);
}

struct Point
{
    float  f = 0.0;
    double g = 0.0;
}

Compile with -O -m64 on Linux, and the code for test() is:

                push    RBP
                mov     RBP,RSP
                sub     RSP,010h
                lea     RAX,-010h[RBP]
                xor     ECX,ECX
                mov     [RAX],RCX
                mov     8[RAX],RCX
                fld     float ptr -010h[RBP]
                fldz
                fucomip          <--- using x87
                fstp    ST
                jne     L25
                mov     RSP,RBP
                pop     RBP
                ret
L25:            mov     ESI,5
                mov     EDI,offset FLAT:_TMP0 32
                call      _d_assertp PC32
                mov     RSP,RBP
                pop     RBP
                ret

It should be using XMM instructions instead.

--
Apr 17 2021