Bug 21676 – [ICE][SIMD] DMD crashing with SIMD + optimizations + inlining

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2021-03-02T18:34:37Z
Last change time
2022-04-22T21:59:53Z
Keywords
backend, ice, ice-on-valid-code, pull, SIMD
Assigned to
No Owner
Creator
ponce
See also
https://issues.dlang.org/show_bug.cgi?id=21727

Comments

Comment #0 by aliloko — 2021-03-02T18:34:37Z
DMD 2.096-b1 either crash (or loops a long time) with the following code: -------------- repro.d ------------- import core.simd; double2 loadUnaligned(const(double)* pvec) { double2 result; foreach(i; 0..2) { result[i] = pvec[i]; } return result; } double2 _mm_setr_pd (double e1, double e0) { double[2] result = [e1, e0]; return loadUnaligned(result.ptr); } double2 fun (double2 a, double2 b) { a[0] = (a[0] < b[0]) ? a[0] : b[0]; return a; } void main(string[] args) { double2 A = _mm_setr_pd(1.0, 2.0); double2 B = _mm_setr_pd(4.0, 1.0); double2 C = fun(A, B); assert(C.array[0] == 1.0); assert(C.array[1] == 1.0); } -------------------------------------------------- Run it with: dmd -m64 -O -inline repro.d echo %errorlevel% Notes: - static foreach avoids the issue - both -O and -inline needed - works OK and assert pass with LDC - DMD 2.088 gives more details: ----------- ERROR: This is a compiler bug. Please report it via https://issues.dlang.org/enter_bug.cgi with, preferably, a reduced, reproducible example and the information below. DustMite (https://github.com/CyberShadow/DustMite/wiki) can help with the reduction. --- DMD v2.088.1-dirty predefs DigitalMars Windows CRuntime_Microsoft CppRuntime_Microsoft LittleEndian D_Version2 all D_SIMD D_InlineAsm_X86_64 X86_64 Win64 D_LP64 assert D_ModuleInfo D_Exceptions D_TypeInfo D_HardFloat binary c:\d\dmd_2.088.1\windows\bin\dmd.exe version v2.088.1-dirty config c:\d\dmd_2.088.1\windows\bin\sc.ini DFLAGS -Ic:\d\dmd_2.088.1\windows\bin\..\..\src\phobos -Ic:\d\dmd_2.088.1\windows\bin\..\..\src\druntime\import -L/OPT:NOICF --- object.Error@(0): Illegal Instruction ---------------- 0x00631AD4
Comment #1 by dkorpel — 2022-04-11T09:25:04Z
Just this: ``` double2 fun(double2 a, double2 b) { a[0] = (a[0] < b[0]) ? a[0] : b[0]; return a; } ``` Already fails with `dmd -O` on linux: ``` findreg(0, line=180, file='src/dmd/backend/cgxmm.d', function = '_D5test_3funFNhG2dQfZQi') dmd: src/dmd/backend/cgcod.d:1868: Assertion `0' failed. ```
Comment #2 by dlang-bot — 2022-04-12T13:22:25Z
@dkorpel updated dlang/dmd pull request #13977 "Fix issue 21673, 23009 - don't put SIMD variables in registers" fixing this issue: - Fix issue 21673, 21676, 23009 - don't put SIMD variables in registers https://github.com/dlang/dmd/pull/13977
Comment #3 by dlang-bot — 2022-04-12T23:59:56Z
dlang/dmd pull request #13977 "Fix issue 21673, 21676, 23009 - don't put SIMD variables in registers" was merged into stable: - 3423d410d9415a0120d7b21ec76fe2ace1c7d863 by Dennis Korpel: Fix issue 21673, 21676, 23009 - don't put SIMD variables in registers https://github.com/dlang/dmd/pull/13977
Comment #4 by dlang-bot — 2022-04-22T21:59:53Z
dlang/dmd pull request #14020 "merge stable" was merged into master: - c19baac0b667f36d4fd623e06a7728468acb3f56 by Dennis Korpel: Fix issue 21673, 21676, 23009 - don't put SIMD variables in registers https://github.com/dlang/dmd/pull/14020