Debian Codegraph @

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

raw
1 // { dg-additional-options "-mavx" { target avx_runtime } }
2 // { dg-skip-if "needs gcc/config.d" { ! d_runtime } }
3 import gcc.simd;
4
5 void main()
6 {
7 ubyte[32] data;
8
9 // to test all alignments from 1 ~ 16
10 foreach (i; 0..16)
11 {
12 ubyte* d = &data[i];
13
14 void test(T)()
15 {
16 T v;
17
18 // populate v` with data
19 ubyte* ptrToV = cast(ubyte*)&v;
20 foreach (j; 0..T.sizeof)
21 ptrToV[j] = cast(ubyte)j;
22
23 // store `v` to location pointed to by `d`
24 storeUnaligned(cast(T*)d, v);
25
26 // check that the data was stored correctly
27 foreach (j; 0..T.sizeof)
28 assert(ptrToV[j] == d[j]);
29 }
30
31 static if (__traits(compiles, __vector(void[16])))
32 test!(__vector(void[16]))();
33 static if (__traits(compiles, __vector(byte[16])))
34 test!(__vector(byte[16]))();
35 static if (__traits(compiles, __vector(ubyte[16])))
36 test!(__vector(ubyte[16]))();
37 static if (__traits(compiles, __vector(short[8])))
38 test!(__vector(short[8]))();
39 static if (__traits(compiles, __vector(ushort[8])))
40 test!(__vector(ushort[8]))();
41 static if (__traits(compiles, __vector(int[4])))
42 test!(__vector(int[4]))();
43 static if (__traits(compiles, __vector(uint[4])))
44 test!(__vector(uint[4]))();
45 static if (__traits(compiles, __vector(long[2])))
46 test!(__vector(long[2]))();
47 static if (__traits(compiles, __vector(ulong[2])))
48 test!(__vector(ulong[2]))();
49 static if (__traits(compiles, __vector(double[2])))
50 test!(__vector(double[2]))();
51 static if (__traits(compiles, __vector(float[4])))
52 test!(__vector(float[4]))();
53 }
54 }