Debian Codegraph @

gcc/testsuite/gcc.target/i386/avx10_2-512-vcvtph2ibs-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 <limits.h>
12 #include <string.h>
13
14 #define SIZE (AVX512F_LEN / 16)
15 #include "avx512f-mask-type.h"
16
17 static void
18 CALC (_Float16 *s, short *r)
19 {
20 int i;
21 unsigned char tmp;
22
23 for (i = 0; i < SIZE; i++)
24 {
25 if (s[i] > SCHAR_MAX)
26 tmp = SCHAR_MAX;
27 else if (s[i] < SCHAR_MIN)
28 tmp = SCHAR_MIN;
29 else
30 tmp = __builtin_nearbyintf16(s[i]);
31 r[i] = (unsigned short) tmp;
32 }
33 }
34
35 void
36 TEST (void)
37 {
38 UNION_TYPE (AVX512F_LEN, h) s;
39 UNION_TYPE (AVX512F_LEN, i_w) res1, res2, res3;
40 MASK_TYPE mask = MASK_VALUE;
41 short res_ref[SIZE] = { 0 }, res_ref2[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_ph_epi8) (s.x);
54 res2.x = INTRINSIC (_mask_ipcvts_ph_epi8) (res2.x, mask, s.x);
55 res3.x = INTRINSIC (_maskz_ipcvts_ph_epi8) (mask, s.x);
56
57 CALC (s.a, res_ref);
58 memcpy(res_ref2, res_ref, sizeof(res_ref));
59
60 if (UNION_CHECK (AVX512F_LEN, i_w) (res1, res_ref))
61 abort ();
62
63 MASK_MERGE (i_w) (res_ref, mask, SIZE);
64 if (UNION_CHECK (AVX512F_LEN, i_w) (res2, res_ref))
65 abort ();
66
67 MASK_ZERO (i_w) (res_ref, mask, SIZE);
68 if (UNION_CHECK (AVX512F_LEN, i_w) (res3, res_ref))
69 abort ();
70
71 #if AVX512F_LEN == 512
72 for (i = 0; i < SIZE; i++)
73 res2.a[i] = DEFAULT_VALUE;
74
75 res1.x = INTRINSIC (_ipcvts_roundph_epi8) (s.x, 8);
76 res2.x = INTRINSIC (_mask_ipcvts_roundph_epi8) (res2.x, mask, s.x, 8);
77 res3.x = INTRINSIC (_maskz_ipcvts_roundph_epi8) (mask, s.x, 8);
78
79 if (UNION_CHECK (AVX512F_LEN, i_w) (res1, res_ref2))
80 abort ();
81
82 MASK_MERGE (i_w) (res_ref2, mask, SIZE);
83 if (UNION_CHECK (AVX512F_LEN, i_w) (res2, res_ref2))
84 abort ();
85
86 MASK_ZERO (i_w) (res_ref2, mask, SIZE);
87 if (UNION_CHECK (AVX512F_LEN, i_w) (res3, res_ref2))
88 abort ();
89 #endif
90 }