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