2008-05-30 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse2-init-v4si-1.c
blob71e27be60804c43b71670ff088ce88002bcedc36
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 int *v, int j)
16 union
18 __m128i x;
19 unsigned int i[4];
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 int *v)
49 __m128i x;
51 x = _mm_set_epi32 (0, 0, 0, v[0]);
52 check (x, v, 0);
53 x = _mm_set_epi32 (0, 0, v[1], 0);
54 check (x, v, 1);
55 x = _mm_set_epi32 (0, v[2], 0, 0);
56 check (x, v, 2);
57 x = _mm_set_epi32 (v[3], 0, 0, 0);
58 check (x, v, 3);
61 static void
62 sse2_test (void)
64 unsigned int v[4]
65 = { 0x7B5B5465, 0x73745665, 0x63746F72, 0x5D53475D };
66 test (v);