Bug 21727 – [ICE][SIMD] Windows-only DMD crash with SIMD + optimizations + inlining

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2021-03-18T05:45:09Z
Last change time
2021-07-17T09:04:43Z
Keywords
backend, ice, ice-on-valid-code, SIMD
Assigned to
No Owner
Creator
Nathan S.
See also
https://issues.dlang.org/show_bug.cgi?id=21676

Comments

Comment #0 by n8sh.secondary — 2021-03-18T05:45:09Z
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]); } ---
Comment #1 by n8sh.secondary — 2021-07-16T22:04:23Z
Windows-only crash no longer occurs as of DMD 2.097.
Comment #2 by dlang-bot — 2021-07-17T09:04:43Z
dlang/dmd pull request #12884 "Issue 21727: add test to prevent regression" was merged into master: - 708590e1a2853956d6751c5ee7614c7ad5d48e1a by Nathan Sashihara: Issue 21727: add test to prevent regression https://github.com/dlang/dmd/pull/12884