2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx-vperm2f128-256-2.c
blobdb9c65bce2caf74a562ecac42e44f422fab9c2ad
1 /* { dg-do run } */
2 /* { dg-require-effective-target avx } */
3 /* { dg-options "-O2 -mavx" } */
5 #include "avx-check.h"
7 #ifndef IMM8
8 # define IMM8 99
9 #endif
12 void static
13 avx_test ()
15 union256d source1, source2, u;
16 double s1[4]={1, 2, 3, 4};
17 double s2[4]={5, 6, 7, 8};
18 double e[4];
20 source1.x = _mm256_loadu_pd(s1);
21 source2.x = _mm256_loadu_pd(s2);
22 u.x = _mm256_permute2f128_pd(source1.x, source2.x, IMM8);
24 if(IMM8 & 8) e[0] = e[1] = 0;
25 else{
26 e[0] = (IMM8 & 2 ? s2 : s1)[(IMM8 & 1) * 2];
27 e[1] = (IMM8 & 2 ? s2 : s1)[(IMM8 & 1) * 2 + 1];
29 if(IMM8 & 128) e[3] = e[3] = 0;
30 else{
31 unsigned m = (IMM8 >> 4) & 3;
32 e[2] = (m & 2 ? s2 : s1)[(m & 1) * 2];
33 e[3] = (m & 2 ? s2 : s1)[(m & 1) * 2 + 1];
36 if (check_union256d (u, e))
37 abort ();