2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_1-pinsrd.c
blob7a5d5fbc9140c07a1c3cf99829f2e598cf893409
1 /* { dg-do run } */
2 /* { dg-require-effective-target sse4 } */
3 /* { dg-options "-O2 -msse4.1" } */
5 #ifndef CHECK_H
6 #define CHECK_H "sse4_1-check.h"
7 #endif
9 #ifndef TEST
10 #define TEST sse4_1_test
11 #endif
13 #include CHECK_H
15 #include <smmintrin.h>
16 #include <string.h>
18 #define msk0 0x00
19 #define msk1 0x01
20 #define msk2 0x02
21 #define msk3 0x03
23 static void
24 TEST (void)
26 union
28 __m128i x;
29 unsigned int i[4];
30 } res [4], val, tmp;
31 static unsigned int ins[4] = { 3, 4, 5, 6 };
32 int masks[4];
33 int i;
35 val.i[0] = 55;
36 val.i[1] = 55;
37 val.i[2] = 55;
38 val.i[3] = 55;
40 /* Check pinsrd imm8, r32, xmm. */
41 res[0].x = _mm_insert_epi32 (val.x, ins[0], msk0);
42 res[1].x = _mm_insert_epi32 (val.x, ins[0], msk1);
43 res[2].x = _mm_insert_epi32 (val.x, ins[0], msk2);
44 res[3].x = _mm_insert_epi32 (val.x, ins[0], msk3);
46 masks[0] = msk0;
47 masks[1] = msk1;
48 masks[2] = msk2;
49 masks[3] = msk3;
51 for (i = 0; i < 4; i++)
53 tmp.x = val.x;
54 tmp.i[masks[i]] = ins[0];
55 if (memcmp (&tmp, &res[i], sizeof (tmp)))
56 abort ();
59 /* Check pinsrd imm8, m32, xmm. */
60 for (i = 0; i < 4; i++)
62 res[i].x = _mm_insert_epi32 (val.x, ins[i], msk0);
63 masks[i] = msk0;
66 for (i = 0; i < 4; i++)
68 tmp.x = val.x;
69 tmp.i[masks[i]] = ins[i];
70 if (memcmp (&tmp, &res[i], sizeof (tmp)))
71 abort ();