Update concepts branch to revision 131834
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_1-blendvps.c
blob7ff4649004d1fe328d3a91f5dd6b9bf8eb037893
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 static void
13 init_blendvps (float *src1, float *src2, float *mask)
15 int i, msk, sign = 1;
17 msk = -1;
18 for (i = 0; i < NUM * 4; i++)
20 if((i % 4) == 0)
21 msk++;
22 src1[i] = i* (i + 1) * sign;
23 src2[i] = (i + 20) * sign;
24 mask[i] = (i + 120) * i;
25 if( (msk & (1 << (i % 4))))
26 mask[i] = -mask[i];
27 sign = -sign;
31 static int
32 check_blendvps (__m128 *dst, float *src1, float *src2,
33 float *mask)
35 float tmp[4];
36 int j;
38 memcpy (&tmp[0], src1, sizeof (tmp));
39 for (j = 0; j < 4; j++)
40 if (mask [j] < 0.0)
41 tmp[j] = src2[j];
43 return memcmp (dst, &tmp[0], sizeof (tmp));
46 static void
47 sse4_1_test (void)
49 union
51 __m128 x[NUM];
52 float f[NUM * 4];
53 } dst, src1, src2, mask;
54 int i;
56 init_blendvps (src1.f, src2.f, mask.f);
58 for (i = 0; i < NUM; i++)
60 dst.x[i] = _mm_blendv_ps (src1.x[i], src2.x[i], mask.x[i]);
61 if (check_blendvps (&dst.x[i], &src1.f[i * 4], &src2.f[i * 4],
62 &mask.f[i * 4]))
63 abort ();