2018-05-17 Richard Biener <rguenther@suse.de>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx2-vpackuswb-2.c
blobabeee3e6d0afb3a6ff8a84bbce5a3630f81dea01
1 /* { dg-do run } */
2 /* { dg-options "-mavx2 -O2" } */
3 /* { dg-require-effective-target avx2 } */
5 #include "avx2-check.h"
7 static unsigned char
8 short_to_ubyte (short iVal)
10 unsigned char sVal;
12 if (iVal < 0)
13 sVal = 0;
14 else if (iVal > 255)
15 sVal = 255;
16 else
17 sVal = iVal;
19 return sVal;
22 void static
23 avx2_test (void)
25 union256i_w s1, s2;
26 union256i_b u;
27 char e[32];
28 int i;
30 s1.x = _mm256_set_epi16 (1, 2, 3, 4, 6500, 20, 30, 90,
31 88, 44, 33, 22, 11, 98, 78, -1000);
33 s2.x = _mm256_set_epi16 (88, 44, 33, 22, 11, 98, 76, -650,
34 1, 2, 3, 4, 6500, 20, 30, 90);
36 u.x = _mm256_packus_epi16 (s1.x, s2.x);
38 for (i = 0; i < 8; i++)
40 e[i] = short_to_ubyte (s1.a[i]);
41 e[i + 8] = short_to_ubyte (s2.a[i]);
42 e[i + 16] = short_to_ubyte (s1.a[i + 8]);
43 e[i + 24] = short_to_ubyte (s2.a[i + 8]);
46 if (check_union256i_b (u, e))
47 abort ();