2018-05-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx-vpermilps-256-2.c
blob9890410b494333d06694eb5e0b81cbe8c416e00b
1 /* { dg-do run } */
2 /* { dg-require-effective-target avx } */
3 /* { dg-options "-O2 -mavx" } */
5 #include "avx-check.h"
7 #ifndef CTRL
8 #define CTRL 233
9 #endif
11 #define mask_v(pos) ((CTRL & (0x3 << (pos))) >> (pos))
13 void static
14 avx_test ()
16 union256 u, s;
17 union256i_q ctl;
18 int m[8] = {mask_v(0), mask_v(1), mask_v(2), mask_v(3), mask_v(4), mask_v(5), mask_v(6), mask_v(7)};
19 float e[8];
21 s.x = _mm256_set_ps (1, 2, 3, 4, 5, 6, 7, 8);
22 ctl.x = _mm256_loadu_si256((__m256i*) m);
23 u.x = _mm256_permutevar_ps(s.x, ctl.x);
25 e[0] = s.a[0 + (m[0] & 0x03)];
26 e[1] = s.a[0 + (m[1] & 0x03)];
27 e[2] = s.a[0 + (m[2] & 0x03)];
28 e[3] = s.a[0 + (m[3] & 0x03)];
29 e[4] = s.a[4 + (m[4] & 0x03)];
30 e[5] = s.a[4 + (m[5] & 0x03)];
31 e[6] = s.a[4 + (m[6] & 0x03)];
32 e[7] = s.a[4 + (m[7] & 0x03)];
34 if (check_union256 (u, e))
35 abort ();