Debian Codegraph @

gcc/testsuite/gcc.target/aarch64/advsimd-intrinsics/vdiv_f16_1.c

raw
1 /* { dg-require-effective-target arm_v8_2a_fp16_neon_hw } */
2 /* { dg-add-options arm_v8_2a_fp16_neon } */
3 /* { dg-skip-if "" { arm*-*-* } } */
4
5 #include <arm_neon.h>
6 #include "arm-neon-ref.h"
7 #include "compute-ref-data.h"
8
9 #define FP16_C(a) ((__fp16) a)
10 #define A FP16_C (13.4)
11 #define B FP16_C (-56.8)
12 #define C FP16_C (-34.8)
13 #define D FP16_C (12)
14 #define E FP16_C (63.1)
15 #define F FP16_C (19.1)
16 #define G FP16_C (-4.8)
17 #define H FP16_C (77)
18
19 #define I FP16_C (0.7)
20 #define J FP16_C (-78)
21 #define K FP16_C (11.23)
22 #define L FP16_C (98)
23 #define M FP16_C (87.1)
24 #define N FP16_C (-8)
25 #define O FP16_C (-1.1)
26 #define P FP16_C (-9.7)
27
28 /* Expected results for vdiv. */
29 VECT_VAR_DECL (expected_div_static, hfloat, 16, 4) []
30 = { 0x32CC /* A / E. */, 0xC1F3 /* B / F. */,
31 0x4740 /* C / G. */, 0x30FD /* D / H. */ };
32
33 VECT_VAR_DECL (expected_div_static, hfloat, 16, 8) []
34 = { 0x32CC /* A / E. */, 0xC1F3 /* B / F. */,
35 0x4740 /* C / G. */, 0x30FD /* D / H. */,
36 0x201D /* I / M. */, 0x48E0 /* J / N. */,
37 0xC91B /* K / O. */, 0xC90D /* L / P. */ };
38
39 void exec_vdiv_f16 (void)
40 {
41 #undef TEST_MSG
42 #define TEST_MSG "VDIV (FP16)"
43 clean_results ();
44
45 DECL_VARIABLE(vsrc_1, float, 16, 4);
46 DECL_VARIABLE(vsrc_2, float, 16, 4);
47 VECT_VAR_DECL (buf_src_1, float, 16, 4) [] = {A, B, C, D};
48 VECT_VAR_DECL (buf_src_2, float, 16, 4) [] = {E, F, G, H};
49 VLOAD (vsrc_1, buf_src_1, , float, f, 16, 4);
50 VLOAD (vsrc_2, buf_src_2, , float, f, 16, 4);
51
52 DECL_VARIABLE (vector_res, float, 16, 4)
53 = vdiv_f16 (VECT_VAR (vsrc_1, float, 16, 4),
54 VECT_VAR (vsrc_2, float, 16, 4));
55 vst1_f16 (VECT_VAR (result, float, 16, 4),
56 VECT_VAR (vector_res, float, 16, 4));
57
58 CHECK_FP (TEST_MSG, float, 16, 4, PRIx16, expected_div_static, "");
59
60 #undef TEST_MSG
61 #define TEST_MSG "VDIVQ (FP16)"
62 clean_results ();
63
64 DECL_VARIABLE(vsrc_1, float, 16, 8);
65 DECL_VARIABLE(vsrc_2, float, 16, 8);
66 VECT_VAR_DECL (buf_src_1, float, 16, 8) [] = {A, B, C, D, I, J, K, L};
67 VECT_VAR_DECL (buf_src_2, float, 16, 8) [] = {E, F, G, H, M, N, O, P};
68 VLOAD (vsrc_1, buf_src_1, q, float, f, 16, 8);
69 VLOAD (vsrc_2, buf_src_2, q, float, f, 16, 8);
70
71 DECL_VARIABLE (vector_res, float, 16, 8)
72 = vdivq_f16 (VECT_VAR (vsrc_1, float, 16, 8),
73 VECT_VAR (vsrc_2, float, 16, 8));
74 vst1q_f16 (VECT_VAR (result, float, 16, 8),
75 VECT_VAR (vector_res, float, 16, 8));
76
77 CHECK_FP (TEST_MSG, float, 16, 8, PRIx16, expected_div_static, "");
78 }
79
80 int
81 main (void)
82 {
83 exec_vdiv_f16 ();
84 return 0;
85 }