c++: fix explicit/copy problem [PR109247]
[official-gcc.git] / gcc / testsuite / gdc.dg / torture / simd_store.d
blob234c020da85df6b1b769667834cc3a91b7fbd6b8
1 // { dg-additional-options "-mavx" { target avx_runtime } }
2 // { dg-skip-if "needs gcc/config.d" { ! d_runtime } }
3 import gcc.simd;
5 void main()
7 ubyte[32] data;
9 // to test all alignments from 1 ~ 16
10 foreach (i; 0..16)
12 ubyte* d = &data[i];
14 void test(T)()
16 T v;
18 // populate v` with data
19 ubyte* ptrToV = cast(ubyte*)&v;
20 foreach (j; 0..T.sizeof)
21 ptrToV[j] = cast(ubyte)j;
23 // store `v` to location pointed to by `d`
24 storeUnaligned(cast(T*)d, v);
26 // check that the data was stored correctly
27 foreach (j; 0..T.sizeof)
28 assert(ptrToV[j] == d[j]);
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]))();