www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23418] New: double argument is passed on stack, but assumed

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

          Issue ID: 23418
           Summary: double argument is passed on stack, but assumed to be
                    in XMM0 register
           Product: D
           Version: D2
          Hardware: x86
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

bool test_eqz(double x) { return x == 0; }

int abc(int i)
{
    test_eqz(123);
    return 2;
}

compiled with -m32 -O yields:

_D5test38test_eqzFfZb:
                xorps   XMM1,XMM1
                ucomiss XMM1,XMM0  <--- XMM0 should be loaded from stack!
                jp      LA
                je      LE
LA:             xor     EAX,EAX
                jmp short       L13
LE:             mov     EAX,1
L13:            ret     4          <--- correctly popped from stack
                add     [EAX],AL

_D5test33abcFiZi:
                sub     ESP,018h
                movss   XMM0,_D5test312__ModuleInfoZ SYM32[03h]
                sub     ESP,4
                movss   [ESP],XMM0  <--- XMMO passed on stack!
                call      _D5test38test_eqzFfZb PC32
                add     ESP,0Ch
                add     ESP,0Ch
                mov     EAX,2
                ret

--
Oct 15 2022