Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.target / i386 / sse4_1-insertps-1.c
blob2f5741288c294a416475b4fd80a53a20ac5ee1a4
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 0x01
19 #define msk1 0x10
20 #define msk2 0x29
21 #define msk3 0x30
23 #define msk4 0xFC
24 #define msk5 0x05
25 #define msk6 0x0A
26 #define msk7 0x0F
28 static void
29 TEST (void)
31 union
33 __m128 x;
34 float f[4];
35 } res[8], val1, val2, tmp;
36 int masks[8];
37 int i, j;
39 val2.f[0] = 55.0;
40 val2.f[1] = 55.0;
41 val2.f[2] = 55.0;
42 val2.f[3] = 55.0;
44 val1.f[0] = 1.;
45 val1.f[1] = 2.;
46 val1.f[2] = 3.;
47 val1.f[3] = 4.;
49 res[0].x = _mm_insert_ps (val2.x, val1.x, msk0);
50 res[1].x = _mm_insert_ps (val2.x, val1.x, msk1);
51 res[2].x = _mm_insert_ps (val2.x, val1.x, msk2);
52 res[3].x = _mm_insert_ps (val2.x, val1.x, msk3);
54 masks[0] = msk0;
55 masks[1] = msk1;
56 masks[2] = msk2;
57 masks[3] = msk3;
59 for (i = 0; i < 4; i++)
60 res[i + 4].x = _mm_insert_ps (val2.x, val1.x, msk4);
62 masks[4] = msk4;
63 masks[5] = msk4;
64 masks[6] = msk4;
65 masks[7] = msk4;
67 for (i=0; i < 8; i++)
69 tmp = val2;
70 tmp.f[(masks[i] & 0x30) >> 4] = val1.f[(masks[i] & 0xC0) >> 6];
72 for (j = 0; j < 4; j++)
73 if (masks[i] & (0x1 << j))
74 tmp.f[j] = 0.f;
76 if (memcmp (&res[i], &tmp, sizeof (tmp)))
77 abort ();