2014-04-15 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx2-vpackusdw-2.c
blobafc102610f3a2e6fbb287f8fa35a32c5bd104b88
1 /* { dg-do run } */
2 /* { dg-options "-mavx2 -O2" } */
3 /* { dg-require-effective-target avx2 } */
5 #include "avx2-check.h"
7 static unsigned short
8 int_to_ushort (int iVal)
10 unsigned short sVal;
12 if (iVal < 0)
13 sVal = 0;
14 else if (iVal > 65536)
15 sVal = 65535;
16 else
17 sVal = iVal;
19 return sVal;
22 void static
23 avx2_test (void)
25 union256i_d s1, s2;
26 union256i_w u;
27 unsigned short e[16];
28 int i;
30 s1.x = _mm256_set_epi32 (1, 2, 3, 4, -65000, 20, 30, 90);
32 s2.x = _mm256_set_epi32 (88, 44, 33, 22, 11, 98, 76, 120000);
34 u.x = _mm256_packus_epi32 (s1.x, s2.x);
36 for (i = 0; i < 4; i++)
38 e[i] = int_to_ushort (s1.a[i]);
39 e[i + 4] = int_to_ushort (s2.a[i]);
40 e[i + 8] = int_to_ushort (s1.a[i + 4]);
41 e[i + 12] = int_to_ushort (s2.a[i + 4]);
44 if (check_union256i_w (u, e))
45 abort ();