Debian Codegraph @

gcc/testsuite/gdc.dg/torture/simd_load.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 foreach (i; 0..data.length)
9 {
10 data[i] = cast(ubyte)i;
11 }
12
13 // to test all alignments from 1 ~ 16
14 foreach (i; 0..16)
15 {
16 ubyte* d = &data[i];
17
18 void test(T)()
19 {
20 // load the data
21 T v = loadUnaligned(cast(T*)d);
22
23 // check that the data was loaded correctly
24 ubyte* ptrToV = cast(ubyte*)&v;
25 foreach (j; 0..T.sizeof)
26 assert(ptrToV[j] == d[j]);
27 }
28
29 static if (__traits(compiles, __vector(void[16])))
30 test!(__vector(void[16]))();
31 static if (__traits(compiles, __vector(byte[16])))
32 test!(__vector(byte[16]))();
33 static if (__traits(compiles, __vector(ubyte[16])))
34 test!(__vector(ubyte[16]))();
35 static if (__traits(compiles, __vector(short[8])))
36 test!(__vector(short[8]))();
37 static if (__traits(compiles, __vector(ushort[8])))
38 test!(__vector(ushort[8]))();
39 static if (__traits(compiles, __vector(int[4])))
40 test!(__vector(int[4]))();
41 static if (__traits(compiles, __vector(uint[4])))
42 test!(__vector(uint[4]))();
43 static if (__traits(compiles, __vector(long[2])))
44 test!(__vector(long[2]))();
45 static if (__traits(compiles, __vector(ulong[2])))
46 test!(__vector(ulong[2]))();
47 static if (__traits(compiles, __vector(double[2])))
48 test!(__vector(double[2]))();
49 static if (__traits(compiles, __vector(float[4])))
50 test!(__vector(float[4]))();
51 }
52 }