OSDN Git Service

gcc/
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.target / i386 / sse-init-v4hi-1.c
1 /* { dg-do run } */
2 /* { dg-options "-O2 -msse" } */
3
4 #include "sse-check.h"
5
6 #ifdef DEBUG
7 #include <stdio.h>
8 #endif
9
10 #include <mmintrin.h>
11
12 static void
13 __attribute__((noinline))
14 check (__m64 x, unsigned short *v, int j)
15 {
16   union
17     {
18       __m64 x;
19       unsigned short i[8];
20     } u;
21   unsigned int i;
22
23   u.x = x;
24   
25   for (i = 0; i < sizeof (v) / sizeof (v[0]); i++)
26     if (i == j)
27       {
28         if (v[i] != u.i[i])
29           {
30 #ifdef DEBUG
31             printf ("%i: 0x%x != 0x%x\n", i, v[i], u.i[i]);
32 #endif
33             abort ();
34           }
35       }
36     else if (u.i[i] != 0)
37       {
38 #ifdef DEBUG
39         printf ("%i: 0x%x != 0\n", i, u.i[i]);
40 #endif
41         abort ();
42       }
43 }
44
45 static void
46 __attribute__((noinline))
47 test (unsigned short *v)
48 {
49   __m64 x;
50
51   x = _mm_set_pi16 (0, 0, 0, v[0]);
52   check (x, v, 0);
53   x = _mm_set_pi16 (0, 0, v[1], 0);
54   check (x, v, 1);
55   x = _mm_set_pi16 (0, v[2], 0, 0);
56   check (x, v, 2);
57   x = _mm_set_pi16 (v[3], 0, 0, 0);
58   check (x, v, 3);
59 }
60
61 static void
62 sse_test (void)
63 {
64   unsigned short v[4]
65     = { 0x7B5B, 0x5465, 0x7374, 0x5665};
66   test (v);
67 }