2007-05-22 H.J. Lu <hongjiu.lu@intel.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_1-pinsrd.c
blob85c39a011f86f06e26ac5786856dd567e3470dc2
1 /* { dg-do run { target i?86-*-* x86_64-*-* } } */
2 /* { dg-require-effective-target sse4 } */
3 /* { dg-options "-O2 -msse4.1" } */
5 #include "sse4_1-check.h"
7 #include <smmintrin.h>
8 #include <string.h>
10 #define msk0 0x00
11 #define msk1 0x01
12 #define msk2 0x02
13 #define msk3 0x03
15 static void
16 sse4_1_test (void)
18 union
20 __m128i x;
21 unsigned int i[4];
22 } res [4], val, tmp;
23 static unsigned int ins[4] = { 3, 4, 5, 6 };
24 int masks[4];
25 int i;
27 val.i[0] = 55;
28 val.i[1] = 55;
29 val.i[2] = 55;
30 val.i[3] = 55;
32 /* Check pinsrd imm8, r32, xmm. */
33 res[0].x = _mm_insert_epi32 (val.x, ins[0], msk0);
34 res[1].x = _mm_insert_epi32 (val.x, ins[0], msk1);
35 res[2].x = _mm_insert_epi32 (val.x, ins[0], msk2);
36 res[3].x = _mm_insert_epi32 (val.x, ins[0], msk3);
38 masks[0] = msk0;
39 masks[1] = msk1;
40 masks[2] = msk2;
41 masks[3] = msk3;
43 for (i = 0; i < 4; i++)
45 tmp.x = val.x;
46 tmp.i[masks[i]] = ins[0];
47 if (memcmp (&tmp, &res[i], sizeof (tmp)))
48 abort ();
51 /* Check pinsrd imm8, m32, xmm. */
52 for (i = 0; i < 4; i++)
54 res[i].x = _mm_insert_epi32 (val.x, ins[i], msk0);
55 masks[i] = msk0;
58 for (i = 0; i < 4; i++)
60 tmp.x = val.x;
61 tmp.i[masks[i]] = ins[i];
62 if (memcmp (&tmp, &res[i], sizeof (tmp)))
63 abort ();