2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse2-init-v8hi-1.c
blob3874b2ed526d6b3e288c58763554d63d8975adee
1 /* { dg-do run } */
2 /* { dg-options "-O2 -msse2" } */
4 #include "sse2-check.h"
6 #ifdef DEBUG
7 #include <stdio.h>
8 #endif
10 #include <emmintrin.h>
12 static void
13 __attribute__((noinline))
14 check (__m128i x, unsigned short *v, int j)
16 union
18 __m128i x;
19 unsigned short i[8];
20 } u;
21 unsigned int i;
23 u.x = x;
25 for (i = 0; i < sizeof (v) / sizeof (v[0]); i++)
26 if (i == j)
28 if (v[i] != u.i[i])
30 #ifdef DEBUG
31 printf ("%i: 0x%x != 0x%x\n", i, v[i], u.i[i]);
32 #endif
33 abort ();
36 else if (u.i[i] != 0)
38 #ifdef DEBUG
39 printf ("%i: 0x%x != 0\n", i, u.i[i]);
40 #endif
41 abort ();
45 static void
46 __attribute__((noinline))
47 test (unsigned short *v)
49 __m128i x;
51 x = _mm_set_epi16 (0, 0, 0, 0, 0, 0, 0, v[0]);
52 check (x, v, 0);
53 x = _mm_set_epi16 (0, 0, 0, 0, 0, 0, v[1], 0);
54 check (x, v, 1);
55 x = _mm_set_epi16 (0, 0, 0, 0, 0, v[2], 0, 0);
56 check (x, v, 2);
57 x = _mm_set_epi16 (0, 0, 0, 0, v[3], 0, 0, 0);
58 check (x, v, 3);
59 x = _mm_set_epi16 (0, 0, 0, v[4], 0, 0, 0, 0);
60 check (x, v, 4);
61 x = _mm_set_epi16 (0, 0, v[5], 0, 0, 0, 0, 0);
62 check (x, v, 5);
63 x = _mm_set_epi16 (0, v[6], 0, 0, 0, 0, 0, 0);
64 check (x, v, 6);
65 x = _mm_set_epi16 (v[7], 0, 0, 0, 0, 0, 0, 0);
66 check (x, v, 7);
69 static void
70 sse2_test (void)
72 unsigned short v[8]
73 = { 0x7B5B, 0x5465, 0x7374, 0x5665,
74 0x6374, 0x6F72, 0x5D53, 0x475D };
75 test (v);