Initial support for AVX-512{VL,BW,DQ}
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bw-vpabsw-2.c
blob07e9bfea64f8e9d47b21e5faca25f50904cbb6ae
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw -DAVX512BW" } */
3 /* { dg-require-effective-target avx512bw } */
5 #include "avx512f-helper.h"
7 #define SIZE (AVX512F_LEN / 16)
8 #include "avx512f-mask-type.h"
10 void
11 CALC (short *s, short *r)
13 int i;
15 for (i = 0; i < SIZE; i++)
16 if (s[i] < 0)
17 r[i] = -s[i];
18 else
19 r[i] = s[i];
22 void
23 TEST (void)
25 UNION_TYPE (AVX512F_LEN, i_w) s, res1, res2, res3;
26 MASK_TYPE mask = MASK_VALUE;
27 short res_ref[SIZE];
28 int i;
30 for (i = 0; i < SIZE; i++)
32 s.a[i] = i * 7 + (i << 15) + 356;
33 res2.a[i] = DEFAULT_VALUE;
36 CALC (s.a, res_ref);
38 res1.x = INTRINSIC (_abs_epi16) (s.x);
39 res2.x = INTRINSIC (_mask_abs_epi16) (res2.x, mask, s.x);
40 res3.x = INTRINSIC (_maskz_abs_epi16) (mask, s.x);
42 if (UNION_CHECK (AVX512F_LEN, i_w) (res1, res_ref))
43 abort ();
44 MASK_MERGE (i_w) (res_ref, mask, SIZE);
45 if (UNION_CHECK (AVX512F_LEN, i_w) (res2, res_ref))
46 abort ();
48 MASK_ZERO (i_w) (res_ref, mask, SIZE);
49 if (UNION_CHECK (AVX512F_LEN, i_w) (res3, res_ref))
50 abort ();