Debian Codegraph @

gcc/testsuite/gcc.target/i386/avx10_2-512-vcvtbf162iubs-2.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-O2 -march=x86-64-v3 -mavx10.2" } */
3 /* { dg-require-effective-target avx10_2 } */
4
5 #ifndef AVX10_2
6 #define AVX10_2
7 #define AVX10_2_512
8 #define AVX10_512BIT
9 #endif
10 #include "avx10-helper.h"
11 #include <math.h>
12 #include <limits.h>
13
14 #define SIZE (AVX512F_LEN / 16)
15 #include "avx512f-mask-type.h"
16
17 static void
18 CALC (__bf16 *s, unsigned short *r)
19 {
20 int i;
21 unsigned char tmp;
22
23 for (i = 0; i < SIZE; i++)
24 {
25 if (s[i] > UCHAR_MAX)
26 tmp = UCHAR_MAX;
27 else if (s[i] < 0)
28 tmp = 0;
29 else
30 tmp = nearbyint(_mm_cvtsbh_ss(s[i]));
31 r[i] = (unsigned short)tmp;
32 }
33 }
34
35 void
36 TEST (void)
37 {
38 UNION_TYPE (AVX512F_LEN, bf16_bf) s;
39 UNION_TYPE (AVX512F_LEN, i_uw) res1, res2, res3;
40 MASK_TYPE mask = MASK_VALUE;
41 unsigned short res_ref[SIZE] = { 0 };
42 int i, sign = 1;
43
44 for (i = 0; i < SIZE; i++)
45 {
46 s.a[i] = 1.23 * (i + 2) * sign;
47 sign = -sign;
48 }
49
50 for (i = 0; i < SIZE; i++)
51 res2.a[i] = DEFAULT_VALUE;
52
53 res1.x = INTRINSIC (_ipcvts_bf16_epu8) (s.x);
54 res2.x = INTRINSIC (_mask_ipcvts_bf16_epu8) (res2.x, mask, s.x);
55 res3.x = INTRINSIC (_maskz_ipcvts_bf16_epu8) (mask, s.x);
56
57 CALC (s.a, res_ref);
58
59 if (UNION_CHECK (AVX512F_LEN, i_uw) (res1, res_ref))
60 abort ();
61
62 MASK_MERGE (i_uw) (res_ref, mask, SIZE);
63 if (UNION_CHECK (AVX512F_LEN, i_uw) (res2, res_ref))
64 abort ();
65
66 MASK_ZERO (i_uw) (res_ref, mask, SIZE);
67 if (UNION_CHECK (AVX512F_LEN, i_uw) (res3, res_ref))
68 abort ();
69 }