www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 23050] New: Incorrect disassembly of code with -vasm

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

          Issue ID: 23050
           Summary: Incorrect disassembly of code with -vasm
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

Given:

import core.simd;

void main()
{
}

unittest
{
    align(16) double[2] A = [56.0, -74.0];
}

unittest
{
    double[2] A = [56.0, -75.0];
    double2 R = cast(double2) __simd(XMM.LODUPD, *cast(double2*)A.ptr);
    assert(R.array == A);
}

compiling it with -O -unittest -vasm gives:

_Dmain:
0000:   31 C0                    xor       EAX,EAX
0002:   C3                       ret
_D4test17__unittest_L12_C1FZv:
0000:   F2 0F 10 05 FC FF FF FF  movsd     XMM0,[0FFFFFFFCh][RIP]
0008:   F2 0F 10 0D FC FF FF FF  movsd     XMM1,[0FFFFFFFCh][RIP]
0010:   C3                       ret
_D4test17__unittest_L17_C1FZv:
0000:   55                       push      RBP
0001:   48 8B EC                 mov       RBP,RSP
0004:   48 83 EC 30              sub       RSP,030h
0008:   F2 0F 10 05 FC FF FF FF  movsd     XMM0,[0FFFFFFFCh][RIP]
0010:   F2 48 0F 11 45 E0        movsd     -020h[RBP],XMM0
0016:   F2 0F 10 0D FC FF FF FF  movsd     XMM1,[0FFFFFFFCh][RIP]
001e:   F2 48 0F 11 4D E8        movsd     -018h[RBP],XMM1
0024:   66 0F 10 55 E0           movupd    XMM2,-020h[RBP]
0029:   66 0F 29 55 F0           movapd    -010h[RBP],XMM2
002e:   41 B8 00 00 00 00        mov       EAX,0
0034:   48 8D 4D E0              lea       RCX,-020h[RBP]
0038:   B8 02 00 00 00           mov       EAX,2
003d:   48 89 C2                 mov       RDX,RAX
0040:   48 89 55 D8              mov       -028h[RBP],RDX
0044:   48 8D 55 F0              lea       RDX,-010h[RBP]
0048:   BF 02 00 00 00           mov       EAX,2
004d:   48 89 D6                 mov       RSI,RDX
0050:   48 8B 55 D8              mov       RDX,-028h[RBP]
0054:   E8 00 00 00 00           call      L0
0059:   85 C0                    test      EAX,EAX
005b:   75 0F                    jne       L6c
005d:   BE 15 00 00 00           mov       EAX,015h   !!!!
0062:   BF 00 00 00 00           mov       EAX,0      !!!!
0067:   E8 00 00 00 00           call      L0
006c:   48 8B E5                 mov       RSP,RBP
006f:   5D                       pop       RBP
0070:   C3                       ret
main:
0000:   55                       push      RBP
0001:   48 8B EC                 mov       RBP,RSP
0004:   48 83 EC 10              sub       RSP,010h
0008:   89 7D F0                 mov       -010h[RBP],EDI
000b:   48 89 75 F8              mov       -8[RBP],RSI
000f:   BA 00 00 00 00           mov       EAX,0
0014:   48 8B 75 F8              mov       RSI,-8[RBP]
0018:   8B 7D F0                 mov       EDI,-010h[RBP]
001b:   E8 00 00 00 00           call      L0
0020:   48 8B E5                 mov       RSP,RBP
0023:   5D                       pop       RBP
0024:   C3                       ret
_D4test9__modtestFZv:
0000:   55                       push      RBP
0001:   48 8B EC                 mov       RBP,RSP
0004:   E8 00 00 00 00           call      L0
0009:   E8 00 00 00 00           call      L0
000e:   5D                       pop       RBP
000f:   C3                       ret

The lines marked with !!!! are incorrect.

--
Apr 23 2022