2016-12-21 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / xop-vpermil2pd-1.c
blob83cb5163d02057eef807ae2445334454230a5037
1 /* { dg-do run } */
2 /* { dg-require-effective-target xop } */
3 /* { dg-options "-O2 -mxop" } */
5 #include "xop-check.h"
7 #include <x86intrin.h>
9 #ifndef ZERO_MATCH
10 #define ZERO_MATCH 2
11 #endif
13 static double
14 select2dp(double *src1, double *src2, long long sel)
16 double tmp = 0.0;
18 if ((sel & 0x3) == 0) tmp = src1[0];
19 if ((sel & 0x3) == 1) tmp = src1[1];
20 if ((sel & 0x3) == 2) tmp = src2[0];
21 if ((sel & 0x3) == 3) tmp = src2[1];
23 return tmp;
26 static double
27 sel_and_condzerodp(double *src1, double *src2, long long sel, int imm8)
29 double tmp;
31 tmp = select2dp(src1, src2, sel & 0x3);
33 if (((imm8 & 0x3) == 2) && ((sel & 0x4) == 0x4)) tmp = 0;
34 if (((imm8 & 0x3) == 3) && ((sel & 0x4) == 0x0)) tmp = 0;
36 return tmp;
39 void static
40 xop_test ()
42 union128d s1, s2, u;
43 union128i_q s3;
44 double e[2];
46 s1.x = _mm_set_pd (1, 2);
47 s2.x = _mm_set_pd (3, 4);
48 s3.x = _mm_set_epi64x (1, 2);
49 u.x = _mm_permute2_pd(s1.x, s2.x, s3.x, ZERO_MATCH);
51 e[0] = sel_and_condzerodp (s1.a, s2.a, (s3.a[0] & 0xe)>>1, ZERO_MATCH);
52 e[1] = sel_and_condzerodp (s1.a, s2.a, (s3.a[1] & 0xe)>>1, ZERO_MATCH);
54 if (check_union128d (u, e))
55 abort ();