[ARM/AArch64][testsuite] Add vmlal_n and vmlsl_n tests.
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / advsimd-intrinsics / vfma.c
blob8180108d528219d05dff3d5eb3b231e370ad8fce
1 #include <arm_neon.h>
2 #include "arm-neon-ref.h"
3 #include "compute-ref-data.h"
5 #ifdef __ARM_FEATURE_FMA
6 /* Expected results. */
7 VECT_VAR_DECL(expected,hfloat,32,2) [] = { 0x4438ca3d, 0x44390a3d };
8 VECT_VAR_DECL(expected,hfloat,32,4) [] = { 0x44869eb8, 0x4486beb8, 0x4486deb8, 0x4486feb8 };
9 #ifdef __aarch64__
10 VECT_VAR_DECL(expected,hfloat,64,2) [] = { 0x408906e1532b8520, 0x40890ee1532b8520 };
11 #endif
13 #define TEST_MSG "VFMA/VFMAQ"
15 void exec_vfma (void)
17 /* Basic test: v4=vfma(v1,v2), then store the result. */
18 #define TEST_VFMA(Q, T1, T2, W, N) \
19 VECT_VAR(vector_res, T1, W, N) = \
20 vfma##Q##_##T2##W(VECT_VAR(vector1, T1, W, N), \
21 VECT_VAR(vector2, T1, W, N), \
22 VECT_VAR(vector3, T1, W, N)); \
23 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), VECT_VAR(vector_res, T1, W, N))
25 #ifdef __aarch64__
26 #define CHECK_VFMA_RESULTS(test_name,comment) \
27 { \
28 CHECK_FP(test_name, float, 32, 2, PRIx32, expected, comment); \
29 CHECK_FP(test_name, float, 32, 4, PRIx32, expected, comment); \
30 CHECK_FP(test_name, float, 64, 2, PRIx64, expected, comment); \
32 #define DECL_VFMA_VAR(VAR) \
33 DECL_VARIABLE(VAR, float, 32, 2); \
34 DECL_VARIABLE(VAR, float, 32, 4); \
35 DECL_VARIABLE(VAR, float, 64, 2);
36 #else
37 #define CHECK_VFMA_RESULTS(test_name,comment) \
38 { \
39 CHECK_FP(test_name, float, 32, 2, PRIx32, expected, comment); \
40 CHECK_FP(test_name, float, 32, 4, PRIx32, expected, comment); \
42 #define DECL_VFMA_VAR(VAR) \
43 DECL_VARIABLE(VAR, float, 32, 2); \
44 DECL_VARIABLE(VAR, float, 32, 4);
45 #endif
47 DECL_VFMA_VAR(vector1);
48 DECL_VFMA_VAR(vector2);
49 DECL_VFMA_VAR(vector3);
50 DECL_VFMA_VAR(vector_res);
52 clean_results ();
54 /* Initialize input "vector1" from "buffer". */
55 VLOAD(vector1, buffer, , float, f, 32, 2);
56 VLOAD(vector1, buffer, q, float, f, 32, 4);
57 #ifdef __aarch64__
58 VLOAD(vector1, buffer, q, float, f, 64, 2);
59 #endif
61 /* Choose init value arbitrarily. */
62 VDUP(vector2, , float, f, 32, 2, 9.3f);
63 VDUP(vector2, q, float, f, 32, 4, 29.7f);
64 #ifdef __aarch64__
65 VDUP(vector2, q, float, f, 64, 2, 15.8f);
66 #endif
68 /* Choose init value arbitrarily. */
69 VDUP(vector3, , float, f, 32, 2, 81.2f);
70 VDUP(vector3, q, float, f, 32, 4, 36.8f);
71 #ifdef __aarch64__
72 VDUP(vector3, q, float, f, 64, 2, 51.7f);
73 #endif
75 /* Execute the tests. */
76 TEST_VFMA(, float, f, 32, 2);
77 TEST_VFMA(q, float, f, 32, 4);
78 #ifdef __aarch64__
79 TEST_VFMA(q, float, f, 64, 2);
80 #endif
82 CHECK_VFMA_RESULTS (TEST_MSG, "");
84 #endif
86 int main (void)
88 #ifdef __ARM_FEATURE_FMA
89 exec_vfma ();
90 #endif
91 return 0;