blob: 005fb72fab03a85c121b3391e9a9d4efd131069f [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
26#ifdef __arm__
27#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 */
64 TEST_VDUP(vector, , uint, u, 32, 2, 0x12345678);
Christophe Lyonbd9ecf42011-07-19 16:30:50 +020065 TEST_VDUP(vector, , float, f, 32, 2, 1.9f);
Christophe Lyon073831a2011-01-24 17:37:40 +010066 TEST_VDUP(vector, q, uint, u, 32, 4, 0xABCDEF10);
Christophe Lyonbd9ecf42011-07-19 16:30:50 +020067 TEST_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 */
82 TEST_VDUP(vector, , uint, u, 32, 2, 0xFFFFFFFF);
Christophe Lyonbd9ecf42011-07-19 16:30:50 +020083 TEST_VDUP(vector, , float, f, 32, 2, -10.0f);
Christophe Lyon073831a2011-01-24 17:37:40 +010084 TEST_VDUP(vector, q, uint, u, 32, 4, 0x89081234);
Christophe Lyonbd9ecf42011-07-19 16:30:50 +020085 TEST_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) */
100 TEST_VDUP(vector, , float, f, 32, 2, NAN);
101 TEST_VDUP(vector, q, float, f, 32, 4, HUGE_VALF);
102
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 Lyonbd9ecf42011-07-19 16:30:50 +0200112 TEST_VDUP(vector, , float, f, 32, 2, 0.0f);
113 TEST_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 Lyonbd9ecf42011-07-19 16:30:50 +0200124 TEST_VDUP(vector, , float, f, 32, 2, -0.0f);
Christophe Lyon1b7c8e92011-02-16 18:23:15 +0100125 TEST_VDUP(vector, q, float, f, 32, 4, -HUGE_VALF);
126
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 Lyonbd9ecf42011-07-19 16:30:50 +0200136 TEST_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}