2003-12-26 Guilhem Lavaux <guilhem@kaffe.org>
[official-gcc.git] / gcc / testsuite / gcc.c-torture / execute / simd-2.c
blob2d1b92228f7cffce9b253ca83a557e40c73365c3
1 /*
2 Purpose: Test generic SIMD support, V8HImode. This test should work
3 regardless of if the target has SIMD instructions.
4 */
6 typedef int __attribute__((mode(V8HI))) vecint;
8 vecint i = { 150, 100, 150, 200, 0, 0, 0, 0 };
9 vecint j = { 10, 13, 20, 30, 1, 1, 1, 1 };
10 vecint k;
12 union {
13 vecint v;
14 short i[8];
15 } res;
17 /* This should go away once we can use == and != on vector types. */
18 void
19 verify (int a1, int a2, int a3, int a4,
20 int b1, int b2, int b3, int b4)
22 if (a1 != b1
23 || a2 != b2
24 || a3 != b3
25 || a4 != b4)
26 abort ();
29 int
30 main ()
32 k = i + j;
33 res.v = k;
35 verify (res.i[0], res.i[1], res.i[2], res.i[3], 160, 113, 170, 230);
37 k = i * j;
38 res.v = k;
40 verify (res.i[0], res.i[1], res.i[2], res.i[3], 1500, 1300, 3000, 6000);
42 k = i / j;
43 res.v = k;
45 verify (res.i[0], res.i[1], res.i[2], res.i[3], 15, 7, 7, 6);
47 k = i & j;
48 res.v = k;
50 verify (res.i[0], res.i[1], res.i[2], res.i[3], 2, 4, 20, 8);
52 k = i | j;
53 res.v = k;
55 verify (res.i[0], res.i[1], res.i[2], res.i[3], 158, 109, 150, 222);
57 k = i ^ j;
58 res.v = k;
60 verify (res.i[0], res.i[1], res.i[2], res.i[3], 156, 105, 130, 214);
62 k = -i;
63 res.v = k;
64 verify (res.i[0], res.i[1], res.i[2], res.i[3],
65 -150, -100, -150, -200);
67 k = ~i;
68 res.v = k;
69 verify (res.i[0], res.i[1], res.i[2], res.i[3], -151, -101, -151, -201);
71 exit (0);