Add AMD SSE5 support; Add iterator over function arguments; Add stdarg_p, prototype_p...
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / sse4_1-blendpd.c
blobf938e2fffb63f5090a1050a3d1d51042f1c926f0
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 #ifndef MASK
13 #define MASK 0x03
14 #endif
16 static void
17 init_blendpd (double *src1, double *src2)
19 int i, sign = 1;
21 for (i = 0; i < NUM * 2; i++)
23 src1[i] = i * i * sign;
24 src2[i] = (i + 20) * sign;
25 sign = -sign;
29 static int
30 check_blendpd (__m128d *dst, double *src1, double *src2)
32 double tmp[2];
33 int j;
35 memcpy (&tmp[0], src1, sizeof (tmp));
37 for(j = 0; j < 2; j++)
38 if ((MASK & (1 << j)))
39 tmp[j] = src2[j];
41 return memcmp (dst, &tmp[0], sizeof (tmp));
44 static void
45 sse4_1_test (void)
47 __m128d x, y;
48 union
50 __m128d x[NUM];
51 double d[NUM * 2];
52 } dst, src1, src2;
53 union
55 __m128d x;
56 double d[2];
57 } src3;
58 int i;
60 init_blendpd (src1.d, src2.d);
62 /* Check blendpd imm8, m128, xmm */
63 for (i = 0; i < NUM; i++)
65 dst.x[i] = _mm_blend_pd (src1.x[i], src2.x[i], MASK);
66 if (check_blendpd (&dst.x[i], &src1.d[i * 2], &src2.d[i * 2]))
67 abort ();
70 /* Check blendpd imm8, xmm, xmm */
71 src3.x = _mm_setzero_pd ();
73 x = _mm_blend_pd (dst.x[2], src3.x, MASK);
74 y = _mm_blend_pd (src3.x, dst.x[2], MASK);
76 if (check_blendpd (&x, &dst.d[4], &src3.d[0]))
77 abort ();
79 if (check_blendpd (&y, &src3.d[0], &dst.d[4]))
80 abort ();