PR inline-asm/84742
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx512bw-vpsrlw-2.c
blob7a8fed39156bc91adb076bea50b454f004190b9f
1 /* { dg-do run } */
2 /* { dg-options "-O2 -mavx512bw" } */
3 /* { dg-require-effective-target avx512bw } */
5 #define AVX512BW
6 #include "avx512f-helper.h"
8 #define SIZE (AVX512F_LEN / 16)
9 #include "avx512f-mask-type.h"
11 void
12 CALC (unsigned short *r, unsigned short *s1, unsigned short *s2)
14 int i;
15 unsigned short count = s2[0];
16 for (i = 0; i < SIZE; i++)
18 r[i] = count < 16 ? (s1[i] >> count) : 0;
22 void
23 TEST (void)
25 int i;
26 UNION_TYPE (AVX512F_LEN, i_w) res1, res2, res3, src1;
27 UNION_TYPE (128, i_w) src2;
28 MASK_TYPE mask = MASK_VALUE;
29 unsigned short res_ref[SIZE];
31 for (i = 0; i < SIZE; i++)
33 src1.a[i] = 2 + 7 * i % 291;
36 for (i = 0; i < 128 / 16; i++)
38 src2.a[i] = 0;
41 src2.a[0] = 1;
42 src2.a[1] = 0;
43 for (i = 0; i < SIZE; i++)
44 res2.a[i] = DEFAULT_VALUE;
46 res1.x = INTRINSIC (_srl_epi16) (src1.x, src2.x);
47 res2.x = INTRINSIC (_mask_srl_epi16) (res2.x, mask, src1.x, src2.x);
48 res3.x = INTRINSIC (_maskz_srl_epi16) (mask, src1.x, src2.x);
50 CALC (res_ref, src1.a, src2.a);
52 if (UNION_CHECK (AVX512F_LEN, i_w) (res1, res_ref))
53 abort ();
55 MASK_MERGE (i_w) (res_ref, mask, SIZE);
56 if (UNION_CHECK (AVX512F_LEN, i_w) (res2, res_ref))
57 abort ();
59 MASK_ZERO (i_w) (res_ref, mask, SIZE);
60 if (UNION_CHECK (AVX512F_LEN, i_w) (res3, res_ref))
61 abort ();
63 src2.a[0] = 17;
64 for (i = 0; i < SIZE; i++)
65 res2.a[i] = DEFAULT_VALUE;
67 res1.x = INTRINSIC (_srl_epi16) (src1.x, src2.x);
68 res2.x = INTRINSIC (_mask_srl_epi16) (res2.x, mask, src1.x, src2.x);
69 res3.x = INTRINSIC (_maskz_srl_epi16) (mask, src1.x, src2.x);
71 CALC (res_ref, src1.a, src2.a);
73 if (UNION_CHECK (AVX512F_LEN, i_w) (res1, res_ref))
74 abort ();
76 MASK_MERGE (i_w) (res_ref, mask, SIZE);
77 if (UNION_CHECK (AVX512F_LEN, i_w) (res2, res_ref))
78 abort ();
80 MASK_ZERO (i_w) (res_ref, mask, SIZE);
81 if (UNION_CHECK (AVX512F_LEN, i_w) (res3, res_ref))
82 abort ();