www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20111] New: asm VCVTPS2PH is not encoded correctly

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

          Issue ID: 20111
           Summary: asm VCVTPS2PH is not encoded correctly
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: thomas.bockman gmail.com

Compiling and then disassembling this test function shows that DMD does not
emit the correct machine code for the VCVTPS2PH instruction. Trying to use this
instruction crashes the program. The equivalent program works on LDC and GDC,
so this is a back-end problem.

__vector(short[8]) vcvtps2ph(__vector(float[4]) value) {
    asm {
        naked;
        vcvtps2ph XMM0, XMM0, 0; // BAD
        ret;
    }
}

I believe that this is the correct encoding (copied from LDC output):

__vector(short[8]) vcvtps2ph(__vector(float[4]) value) {
    asm {
        naked;
        db 0xc4, 0xe3, 0x79, 0x1d, 0xc0, 0x00; // OK?
        ret;
    }
}

The related VCVTPH2PS works - perhaps because it lacks the extra rounding
control argument?

extern(C) __vector(float[4]) vcvtph2ps(__vector(short[8]) bin16s) {
    asm {
        naked;
        vcvtph2ps XMM0, XMM0;
        ret;
    }
}

--
Aug 06 2019