Debian Codegraph @

gcc/testsuite/gdc.dg/torture/simd21727.d

raw
1 // https://issues.dlang.org/show_bug.cgi?id=21727
2 // { dg-additional-options "-mavx" { target avx_runtime } }
3 // { dg-do run { target { avx_runtime || vect_sizes_16B_8B } } }
4 // { dg-skip-if "needs gcc/config.d" { ! d_runtime } }
5 import core.simd;
6
7 @nogc nothrow pure @safe:
8
9 struct Float4
10 {
11 float4 mVector;
12
13 pragma(inline, false) ref typeof(this) doubleInPlace() return
14 @nogc nothrow pure @safe
15 {
16 mVector = mVector + mVector;
17 return this;
18 }
19 }
20
21 pragma(inline, false) Float4 identity(Float4 a)
22 {
23 return a;
24 }
25
26 pragma(inline, true) Float4 twoTimes(const ref Float4 a)
27 {
28 return Float4(a.mVector + a.mVector);
29 }
30
31 pragma(inline, false) Float4 fourTimes(const Float4 a)
32 {
33 auto x = identity(a);
34 auto y = x.doubleInPlace(); // This crashed in dmd.backend.cgxmm.xmmload.
35 auto z = twoTimes(y);
36 return z;
37 }
38
39 void main()
40 {
41 const c = fourTimes(Float4([5,7,11,13]));
42 assert(c.mVector.array == [20, 28, 44, 52]);
43 }