Merge from mainline (165734:167278).
[official-gcc/graphite-test-results.git] / gcc / testsuite / gcc.target / i386 / sse4_1-blendps-2.c
blobb66bbfd3b8cac7908309b2511c997f69c5aabc4c
1 /* { dg-do run } */
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 NUM 20
12 #undef MASK
13 #define MASK 0xe
15 static void
16 init_blendps (float *src1, float *src2)
18 int i, sign = 1;
20 for (i = 0; i < NUM * 4; i++)
22 src1[i] = i * i * sign;
23 src2[i] = (i + 20) * sign;
24 sign = -sign;
28 static int
29 check_blendps (__m128 *dst, float *src1, float *src2)
31 float tmp[4];
32 int j;
34 memcpy (&tmp[0], src1, sizeof (tmp));
35 for (j = 0; j < 4; j++)
36 if ((MASK & (1 << j)))
37 tmp[j] = src2[j];
39 return memcmp (dst, &tmp[0], sizeof (tmp));
42 static void
43 sse4_1_test (void)
45 __m128 x, y;
46 union
48 __m128 x[NUM];
49 float f[NUM * 4];
50 } dst, src1, src2;
51 union
53 __m128 x;
54 float f[4];
55 } src3;
56 int i;
58 init_blendps (src1.f, src2.f);
60 /* Check blendps imm8, m128, xmm */
61 for (i = 0; i < NUM; i++)
63 dst.x[i] = _mm_blend_ps (src1.x[i], src2.x[i], MASK);
64 if (check_blendps (&dst.x[i], &src1.f[i * 4], &src2.f[i * 4]))
65 abort ();
68 /* Check blendps imm8, xmm, xmm */
69 x = _mm_blend_ps (dst.x[2], src3.x, MASK);
70 y = _mm_blend_ps (src3.x, dst.x[2], MASK);
72 if (check_blendps (&x, &dst.f[8], &src3.f[0]))
73 abort ();
75 if (check_blendps (&y, &src3.f[0], &dst.f[8]))
76 abort ();