www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21727] New: [ICE][SIMD] Windows-only DMD crash with SIMD +

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

          Issue ID: 21727
           Summary: [ICE][SIMD] Windows-only DMD crash with SIMD +
                    optimizations + inlining
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com

Possibly related to https://issues.dlang.org/show_bug.cgi?id=21676 but the
compiler doesn't crash in the same place. Given the following code and compiler
flags, DMD will crash calling `dmd.backend.cgxmm.xmmload(tym_t tym, bool
aligned)` with the invalid argument `tym == TYucent`. The crash occurs on
Windows from DMD 2.068--since pragma(inline, true) has been allowed--but
appears not to happen on Linux.

dmd -m64 -O -inline crash.d
---crash.d
import core.simd;

 safe:

struct Float4
{
    float4 mVector;

    pragma(inline, false) ref typeof(this) doubleInPlace() return
    {
        mVector = mVector + mVector;
        return this;
    }
}

pragma(inline, false) Float4 identity(Float4 a)
{
    return a;
}

pragma(inline, true) Float4 twoTimes(const ref Float4 a)
{
    return Float4(cast(float4) __simd(XMM.ADDPS, a.mVector, a.mVector));
}

pragma(inline, false) Float4 fourTimes(const Float4 a)
{
    auto x = identity(a);
    auto y = x.doubleInPlace(); // Crash in dmd.backend.cgxmm.xmmload.
    auto z = twoTimes(y);
    return z;
}

void main()
{
    const c = fourTimes(Float4([5,7,11,13]));
    assert(c.mVector.array == [20, 28, 44, 52]);
}
---

--
Mar 17