[Issue 21835] New: Operation on float should use XMM register, not x87

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 17 07:45:30 UTC 2021


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 at puremagic.com
          Reporter: bugzilla at 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 at 32
                call      _d_assertp at PC32
                mov     RSP,RBP
                pop     RBP
                ret

It should be using XMM instructions instead.

--


More information about the Digitalmars-d-bugs mailing list