| 1 |
/* { dg-do run } */ |
| 2 |
/* { dg-options "-O2 -mavx512bw" } */ |
| 3 |
/* { dg-require-effective-target avx512bw } */ |
| 4 |
|
| 5 |
#define AVX512BW |
| 6 |
#include "avx512f-helper.h" |
| 7 |
|
| 8 |
static char |
| 9 |
short_to_byte (short iVal) |
| 10 |
{ |
| 11 |
short sVal; |
| 12 |
|
| 13 |
if (iVal < -128) |
| 14 |
sVal = -128; |
| 15 |
else if (iVal > 127) |
| 16 |
sVal = 127; |
| 17 |
else |
| 18 |
sVal = iVal; |
| 19 |
|
| 20 |
return sVal; |
| 21 |
} |
| 22 |
|
| 23 |
void |
| 24 |
TEST (void) |
| 25 |
{ |
| 26 |
union512i_w s1, s2; |
| 27 |
union512i_b res1; |
| 28 |
char dst_ref[64]; |
| 29 |
int i; |
| 30 |
|
| 31 |
s1.x = _mm512_set_epi16 (1, 2, 3, 4, 650, 20, 30, 90, 88, 44, 33, 22, 11, 98, 76, -650, |
| 32 |
128, 230, -112, -128, -3, -4, -7, 9, 10, 11, 12, 13, -223, 10, 8, 11); |
| 33 |
s2.x = _mm512_set_epi16 (80, 40, 31, 21, 10, 99, 74, -650, 2, 3, 4, 5, 650, 21, 31, 91, |
| 34 |
280, -140, 310, 20, 9, 98, 73, -651, 3, 4, 5, 6, 651, 22, 32, 92); |
| 35 |
res1.x = _mm512_packs_epi16 (s1.x, s2.x); |
| 36 |
for (int i = 0; i != 8; i++) |
| 37 |
{ |
| 38 |
dst_ref[i] = short_to_byte (s1.a[i]); |
| 39 |
dst_ref[i + 8] = short_to_byte (s2.a[i]); |
| 40 |
dst_ref[i + 16] = short_to_byte (s1.a[i + 8]); |
| 41 |
dst_ref[i + 24] = short_to_byte (s2.a[i + 8]); |
| 42 |
dst_ref[i + 32] = short_to_byte (s1.a[i + 16]); |
| 43 |
dst_ref[i + 40] = short_to_byte (s2.a[i + 16]); |
| 44 |
dst_ref[i + 48] = short_to_byte (s1.a[i + 24]); |
| 45 |
dst_ref[i + 56] = short_to_byte (s2.a[i + 24]); |
| 46 |
} |
| 47 |
|
| 48 |
if (check_union512i_b (res1, dst_ref)) |
| 49 |
abort (); |
| 50 |
} |