New Advanced SIMD intrinsics tests.
[platform/upstream/gcc49.git] / gcc / testsuite / gcc.target / aarch64 / advsimd-intrinsics / cmp_fp_op.inc
1 /* Template file for the validation of comparison operator with
2    floating-point support.
3
4    This file is meant to be included by the relevant test files, which
5    have to define the intrinsic family to test. If a given intrinsic
6    supports variants which are not supported by all the other
7    operators, these can be tested by providing a definition for
8    EXTRA_TESTS.  */
9
10 #include <arm_neon.h>
11 #include "arm-neon-ref.h"
12 #include "compute-ref-data.h"
13
14 /* Additional expected results declaration, they are initialized in
15    each test file.  */
16 extern ARRAY(expected2, uint, 32, 2);
17 extern ARRAY(expected2, uint, 32, 4);
18
19 #define FNNAME1(NAME) exec_ ## NAME
20 #define FNNAME(NAME) FNNAME1(NAME)
21
22 void FNNAME (INSN_NAME) (void)
23 {
24   /* Basic test: y=vcomp(x1,x2), then store the result.  */
25 #define TEST_VCOMP1(INSN, Q, T1, T2, T3, W, N)                          \
26   VECT_VAR(vector_res, T3, W, N) =                                      \
27     INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N),                       \
28                       VECT_VAR(vector2, T1, W, N));                     \
29   vst1##Q##_u##W(VECT_VAR(result, T3, W, N), VECT_VAR(vector_res, T3, W, N))
30
31 #define TEST_VCOMP(INSN, Q, T1, T2, T3, W, N)                           \
32   TEST_VCOMP1(INSN, Q, T1, T2, T3, W, N)
33
34   DECL_VARIABLE(vector, float, 32, 2);
35   DECL_VARIABLE(vector, float, 32, 4);
36   DECL_VARIABLE(vector2, float, 32, 2);
37   DECL_VARIABLE(vector2, float, 32, 4);
38   DECL_VARIABLE(vector_res, uint, 32, 2);
39   DECL_VARIABLE(vector_res, uint, 32, 4);
40
41   clean_results ();
42
43   /* Initialize input "vector" from "buffer".  */
44   VLOAD(vector, buffer, , float, f, 32, 2);
45   VLOAD(vector, buffer, q, float, f, 32, 4);
46
47   /* Choose init value arbitrarily, will be used for vector
48      comparison.  */
49   VDUP(vector2, , float, f, 32, 2, -16.0f);
50   VDUP(vector2, q, float, f, 32, 4, -14.0f);
51
52   /* Apply operator named INSN_NAME.  */
53   TEST_VCOMP(INSN_NAME, , float, f, uint, 32, 2);
54   CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected, "");
55
56   TEST_VCOMP(INSN_NAME, q, float, f, uint, 32, 4);
57   CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected, "");
58
59   /* Test again, with different input values.  */
60   VDUP(vector2, , float, f, 32, 2, -10.0f);
61   VDUP(vector2, q, float, f, 32, 4, 10.0f);
62
63   TEST_VCOMP(INSN_NAME, , float, f, uint, 32, 2);
64   CHECK(TEST_MSG, uint, 32, 2, PRIx32, expected2, "");
65
66   TEST_VCOMP(INSN_NAME, q, float, f, uint, 32, 4);
67   CHECK(TEST_MSG, uint, 32, 4, PRIx32, expected2,"");
68 }
69
70 int main (void)
71 {
72   FNNAME (INSN_NAME) ();
73
74   return 0;
75 }