Debian Codegraph @

gcc/testsuite/gcc.target/i386/avx512fp16-vrndscalesh-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 8
9
10 void NOINLINE
11 emulate_roundscale_sh(V512 * dest, V512 op1,
12 __mmask8 k, int zero_mask)
13 {
14 V512 v1, v2, v3, v4, v5, v6, v7, v8;
15 V512 t1,t2;
16 int i;
17
18 unpack_ph_2twops(op1, &v1, &v2);
19 unpack_ph_2twops(*dest, &v7, &v8);
20 t1.zmm = _mm512_maskz_roundscale_ps (0xffff, v1.zmm, 0x14);
21 t2.zmm = _mm512_maskz_roundscale_ps (0xffff, v2.zmm, 0x14);
22
23 if ((k&1) || !k)
24 v5.f32[0] = t1.f32[0];
25 else if (zero_mask)
26 v5.f32[0] = 0;
27 else
28 v5.f32[0] = v7.f32[0];
29
30 for (i = 1; i < 8; i++)
31 v5.f32[i] = v1.f32[i];
32
33 *dest = pack_twops_2ph(v5, v6);
34 }
35
36 void
37 test_512 (void)
38 {
39 V512 res;
40 V512 exp;
41
42 init_src();
43
44 emulate_roundscale_sh(&exp, src1, 0x1, 0);
45 res.xmmh[0] = _mm_roundscale_round_sh(src1.xmmh[0], src1.xmmh[0], 0x1, 0x08);
46 check_results(&res, &exp, N_ELEMS, "_mm_roundscale_round_sh");
47
48 init_dest(&res, &exp);
49 emulate_roundscale_sh(&exp, src1, 0x1, 0);
50 res.xmmh[0] = _mm_mask_roundscale_round_sh(res.xmmh[0],
51 0x1, src1.xmmh[0], src1.xmmh[0], 0x1, 0x08);
52 check_results(&res, &exp, N_ELEMS, "_mm_mask_roundscale_round_sh");
53
54 emulate_roundscale_sh(&exp, src1, 0x3, 1);
55 res.xmmh[0] = _mm_maskz_roundscale_round_sh(0x3, src1.xmmh[0], src1.xmmh[0], 0x1, 0x08);
56 check_results(&res, &exp, N_ELEMS, "_mm_maskz_roundscale_round_sh");
57
58
59 if (n_errs != 0)
60 abort ();
61 }
62