blob: 5bbbf7cbf2896321724bdcd005b79adfd002fbeb [file] [log] [blame]
Christophe Lyon073831a2011-01-24 17:37:40 +01001/*
2
3Copyright (c) 2009, 2010, 2011 STMicroelectronics
4Written by Christophe Lyon
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22THE SOFTWARE.
23
24*/
25
Christophe Lyon1775be02014-07-10 13:46:54 +020026#if defined(__arm__) || defined(__aarch64__)
Christophe Lyon073831a2011-01-24 17:37:40 +010027#include <arm_neon.h>
28#else
Christophe Lyon0dab5f72011-07-19 17:14:09 +020029#include "stm-arm-neon.h"
Christophe Lyon073831a2011-01-24 17:37:40 +010030#endif
31
32#include "stm-arm-neon-ref.h"
Christophe Lyon1b7c8e92011-02-16 18:23:15 +010033#include <math.h>
Christophe Lyon073831a2011-01-24 17:37:40 +010034
35#define TEST_MSG "VRECPE/VRECPEQ"
36void exec_vrecpe(void)
37{
38 int i;
39
40 /* Basic test: y=vrecpe(x), then store the result. */
41#define TEST_VRECPE(Q, T1, T2, W, N) \
42 VECT_VAR(vector_res, T1, W, N) = \
43 vrecpe##Q##_##T2##W(VECT_VAR(vector, T1, W, N)); \
44 vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N), \
45 VECT_VAR(vector_res, T1, W, N))
46
47 /* With ARM RVCT, we need to declare variables before any executable
48 statement */
49
50 /* No need for 64 bits variants */
51 DECL_VARIABLE(vector, uint, 32, 2);
52 DECL_VARIABLE(vector, uint, 32, 4);
53 DECL_VARIABLE(vector, float, 32, 2);
54 DECL_VARIABLE(vector, float, 32, 4);
55
56 DECL_VARIABLE(vector_res, uint, 32, 2);
57 DECL_VARIABLE(vector_res, uint, 32, 4);
58 DECL_VARIABLE(vector_res, float, 32, 2);
59 DECL_VARIABLE(vector_res, float, 32, 4);
60
61 clean_results ();
62
63 /* Choose init value arbitrarily */
Christophe Lyonf2053672014-12-16 10:26:00 +010064 VDUP(vector, , uint, u, 32, 2, 0x12345678);
65 VDUP(vector, , float, f, 32, 2, 1.9f);
66 VDUP(vector, q, uint, u, 32, 4, 0xABCDEF10);
67 VDUP(vector, q, float, f, 32, 4, 125.0f);
Christophe Lyon073831a2011-01-24 17:37:40 +010068
69 /* Apply the operator */
70 TEST_VRECPE(, uint, u, 32, 2);
71 TEST_VRECPE(, float, f, 32, 2);
72 TEST_VRECPE(q, uint, u, 32, 4);
73 TEST_VRECPE(q, float, f, 32, 4);
74
75 fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " (positive input)");
76 DUMP(TEST_MSG, uint, 32, 2, PRIx32);
77 DUMP(TEST_MSG, uint, 32, 4, PRIx32);
78 DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
79 DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
80
81 /* Choose init value arbitrarily */
Christophe Lyonf2053672014-12-16 10:26:00 +010082 VDUP(vector, , uint, u, 32, 2, 0xFFFFFFFF);
83 VDUP(vector, , float, f, 32, 2, -10.0f);
84 VDUP(vector, q, uint, u, 32, 4, 0x89081234);
85 VDUP(vector, q, float, f, 32, 4, -125.0f);
Christophe Lyon073831a2011-01-24 17:37:40 +010086
87 /* Apply the operator */
88 TEST_VRECPE(, uint, u, 32, 2);
89 TEST_VRECPE(, float, f, 32, 2);
90 TEST_VRECPE(q, uint, u, 32, 4);
91 TEST_VRECPE(q, float, f, 32, 4);
92
93 fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " (negative input)");
94 DUMP(TEST_MSG, uint, 32, 2, PRIx32);
95 DUMP(TEST_MSG, uint, 32, 4, PRIx32);
96 DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
97 DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
Christophe Lyon1b7c8e92011-02-16 18:23:15 +010098
99 /* Test FP variants with special input values (NaN, infinity) */
Christophe Lyonf2053672014-12-16 10:26:00 +0100100 VDUP(vector, , float, f, 32, 2, NAN);
101 VDUP(vector, q, float, f, 32, 4, HUGE_VALF);
Christophe Lyon1b7c8e92011-02-16 18:23:15 +0100102
103 /* Apply the operator */
104 TEST_VRECPE(, float, f, 32, 2);
105 TEST_VRECPE(q, float, f, 32, 4);
106
107 fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " FP special (NaN, infinity)");
108 DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
109 DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
110
111 /* Test FP variants with special input values (zero, large value) */
Christophe Lyonf2053672014-12-16 10:26:00 +0100112 VDUP(vector, , float, f, 32, 2, 0.0f);
113 VDUP(vector, q, float, f, 32, 4, 9.0e37f);
Christophe Lyon1b7c8e92011-02-16 18:23:15 +0100114
115 /* Apply the operator */
116 TEST_VRECPE(, float, f, 32, 2);
117 TEST_VRECPE(q, float, f, 32, 4);
118
119 fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " FP special (zero, large value)");
120 DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
121 DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
122
123 /* Test FP variants with special input values (-0, -infinity) */
Christophe Lyonf2053672014-12-16 10:26:00 +0100124 VDUP(vector, , float, f, 32, 2, -0.0f);
125 VDUP(vector, q, float, f, 32, 4, -HUGE_VALF);
Christophe Lyon1b7c8e92011-02-16 18:23:15 +0100126
127 /* Apply the operator */
128 TEST_VRECPE(, float, f, 32, 2);
129 TEST_VRECPE(q, float, f, 32, 4);
130
131 fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " FP special (-0, -infinity)");
132 DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
133 DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
Christophe Lyon1639b3c2011-02-18 10:37:55 +0100134
135 /* Test FP variants with special input values (large negative value) */
Christophe Lyonf2053672014-12-16 10:26:00 +0100136 VDUP(vector, , float, f, 32, 2, -9.0e37f);
Christophe Lyon1639b3c2011-02-18 10:37:55 +0100137
138 /* Apply the operator */
139 TEST_VRECPE(, float, f, 32, 2);
140
141 fprintf (ref_file, "\n%s %s output:\n", TEST_MSG, " FP special (large negative value)");
142 DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
Christophe Lyon073831a2011-01-24 17:37:40 +0100143}