PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse2-init-v16qi-1.c
blob6dcb4fffa21bda63c4674998e08b7fa80fdf7717
1 /* { dg-do run } */
2 /* { dg-options "-O2 -msse2" } */
3 /* { dg-require-effective-target sse2 } */
5 #include "sse2-check.h"
7 #ifdef DEBUG
8 #include <stdio.h>
9 #endif
11 #include <emmintrin.h>
13 static void
14 __attribute__((noinline))
15 check (__m128i x, unsigned char *v, int j)
17 union
19 __m128i x;
20 unsigned char i[16];
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 char *v)
50 __m128i x;
52 x = _mm_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, v[0]);
53 check (x, v, 0);
54 x = _mm_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, v[1], 0);
55 check (x, v, 1);
56 x = _mm_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, v[2], 0, 0);
57 check (x, v, 2);
58 x = _mm_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, v[3], 0, 0, 0);
59 check (x, v, 3);
60 x = _mm_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, v[4], 0, 0, 0, 0);
61 check (x, v, 4);
62 x = _mm_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, v[5], 0, 0, 0, 0, 0);
63 check (x, v, 5);
64 x = _mm_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, 0, v[6], 0, 0, 0, 0, 0, 0);
65 check (x, v, 6);
66 x = _mm_set_epi8 (0, 0, 0, 0, 0, 0, 0, 0, v[7], 0, 0, 0, 0, 0, 0, 0);
67 check (x, v, 7);
70 static void
71 sse2_test (void)
73 unsigned char v[16]
74 = { 0x7B, 0x5B, 0x54, 0x65, 0x73, 0x74, 0x56, 0x65,
75 0x63, 0x74, 0x6F, 0x72, 0x5D, 0x53, 0x47, 0x5D };
76 test (v);