Debian Codegraph @

gcc/testsuite/gcc.target/i386/avx512fp16-vcvtpd2ph-1b.c

raw
1 /* { dg-do run { target avx512fp16 } } */
2 /* { dg-options "-O2 -mavx512fp16 -mavx512dq" } */
3
4
5 #define AVX512FP16
6 #include "avx512fp16-helper.h"
7
8 #define N_ELEMS (AVX512F_LEN / 64)
9
10 void NOINLINE
11 EMULATE(cvtpd2_ph) (V512 * dest, V512 op1, int n_el,
12 __mmask32 k, int zero_mask)
13 {
14 V512 v1, v2, v3, v4, v5, v6, v7, v8;
15 int i;
16 __mmask16 m1, m2;
17
18 m1 = k & 0xffff;
19 unpack_ph_2twops(*dest, &v7, &v8);
20
21 for (i = 0; i < n_el; i++) {
22 if (((1 << i) & m1) == 0) {
23 if (zero_mask) {
24 v5.f32[i] = 0;
25 }
26 else {
27 v5.u32[i] = v7.u32[i];
28 }
29 }
30 else {
31 v5.f32[i] = op1.f64[i];
32 }
33 }
34 *dest = pack_twops_2ph(v5, v5);
35 for (i = n_el; i < 8; i++)
36 dest->u16[i] = 0;
37 }
38
39 void
40 TEST (void)
41 {
42 V512 res;
43 V512 exp;
44
45 init_src();
46
47 EMULATE(cvtpd2_ph)(&exp, src3f, N_ELEMS, NET_MASK, 0);
48 res.xmmh[0] = INTRINSIC (_cvtpd_ph) (DF(src3f));
49 CHECK_RESULT (&res, &exp, 8, _cvtpd_ph);
50
51 init_dest(&res, &exp);
52 EMULATE(cvtpd2_ph)(&exp, src3f, N_ELEMS, 0xcc, 0);
53 res.xmmh[0] = INTRINSIC (_mask_cvtpd_ph) (res.xmmh[0], 0xcc,
54 DF(src3f));
55 CHECK_RESULT (&res, &exp, 8, _mask_cvtpd_ph);
56
57 EMULATE(cvtpd2_ph)(&exp, src3f, N_ELEMS, 0xf1, 1);
58 res.xmmh[0] = INTRINSIC (_maskz_cvtpd_ph) (0xf1, DF(src3f));
59 CHECK_RESULT (&res, &exp, 8, _maskz_cvtpd_ph);
60
61 #if AVX512F_LEN == 512
62 EMULATE(cvtpd2_ph)(&exp, src3f, N_ELEMS, NET_MASK, 0);
63 res.xmmh[0] = INTRINSIC (_cvt_roundpd_ph) (DF(src3f), _ROUND_NINT);
64 CHECK_RESULT (&res, &exp, 8, _cvt_roundpd_ph);
65
66 init_dest(&res, &exp);
67 EMULATE(cvtpd2_ph)(&exp, src3f, N_ELEMS, 0xcc, 0);
68 res.xmmh[0] = INTRINSIC (_mask_cvt_roundpd_ph) (res.xmmh[0], 0xcc,
69 DF(src3f), _ROUND_NINT);
70 CHECK_RESULT (&res, &exp, 8, _mask_cvt_roundpd_ph);
71
72 EMULATE(cvtpd2_ph)(&exp, src3f, N_ELEMS, 0xf1, 1);
73 res.xmmh[0] = INTRINSIC (_maskz_cvt_roundpd_ph) (0xf1, DF(src3f), _ROUND_NINT);
74 CHECK_RESULT (&res, &exp, 8, _maskz_cvt_roundpd_ph);
75 #endif
76
77 if (n_errs != 0) {
78 abort ();
79 }
80 }
81
82