• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2 
3 Copyright (c) 2009, 2010, 2011 STMicroelectronics
4 Written by Christophe Lyon
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 THE SOFTWARE.
23 
24 */
25 
26 #if defined(__arm__) || defined(__aarch64__)
27 #include <arm_neon.h>
28 #else
29 #include "stm-arm-neon.h"
30 #endif
31 
32 #include "stm-arm-neon-ref.h"
33 #include <math.h>
34 
35 #define TEST_MSG "VRECPS/VRECPSQ"
exec_vrecps(void)36 void exec_vrecps(void)
37 {
38   int i;
39 
40   /* Basic test: y=vrecps(x), then store the result.  */
41 #define TEST_VRECPS(Q, T1, T2, W, N)					\
42   VECT_VAR(vector_res, T1, W, N) =					\
43     vrecps##Q##_##T2##W(VECT_VAR(vector, T1, W, N),			\
44 			VECT_VAR(vector2, T1, W, N));			\
45   vst1##Q##_##T2##W(VECT_VAR(result, T1, W, N),				\
46 		    VECT_VAR(vector_res, T1, W, N))
47 
48     /* With ARM RVCT, we need to declare variables before any executable
49        statement  */
50 
51   /* No need for integer variants */
52   DECL_VARIABLE(vector, float, 32, 2);
53   DECL_VARIABLE(vector, float, 32, 4);
54 
55   DECL_VARIABLE(vector2, float, 32, 2);
56   DECL_VARIABLE(vector2, float, 32, 4);
57 
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   VDUP(vector, , float, f, 32, 2, 12.9f);
65   VDUP(vector, q, float, f, 32, 4, 9.2f);
66 
67   VDUP(vector2, , float, f, 32, 2, 8.9f);
68   VDUP(vector2, q, float, f, 32, 4, 3.2f);
69 
70   /* Apply the operator */
71   TEST_VRECPS(, float, f, 32, 2);
72   TEST_VRECPS(q, float, f, 32, 4);
73 
74   fprintf (ref_file, "\n%s output:\n", TEST_MSG);
75   fprintf (gcc_tests_file, "\n%s output:\n", TEST_MSG);
76   DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
77   DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
78 
79 
80   /* Test FP variants with special input values (NaN) */
81   VDUP(vector, , float, f, 32, 2, NAN);
82   VDUP(vector2, q, float, f, 32, 4, NAN);
83 
84   /* Apply the operator */
85   TEST_VRECPS(, float, f, 32, 2);
86   TEST_VRECPS(q, float, f, 32, 4);
87 
88   fprintf (ref_file, "\n%s output:\n", TEST_MSG " FP special (NAN) and normal values");
89   DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
90   DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
91 
92 
93   /* Test FP variants with special input values (infinity, 0) */
94   VDUP(vector, , float, f, 32, 2, HUGE_VALF);
95   VDUP(vector, q, float, f, 32, 4, 0.0f);
96   VDUP(vector2, q, float, f, 32, 4, 3.2f); /* Restore a normal value */
97 
98   /* Apply the operator */
99   TEST_VRECPS(, float, f, 32, 2);
100   TEST_VRECPS(q, float, f, 32, 4);
101 
102   fprintf (ref_file, "\n%s output:\n", TEST_MSG " FP special (infinity, 0) and normal values");
103   DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
104   DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
105 
106 
107   /* Test FP variants with only special input values (infinity, 0) */
108   VDUP(vector, , float, f, 32, 2, HUGE_VALF);
109   VDUP(vector, q, float, f, 32, 4, 0.0f);
110   VDUP(vector2, , float, f, 32, 2, 0.0f);
111   VDUP(vector2, q, float, f, 32, 4, HUGE_VALF);
112 
113   /* Apply the operator */
114   TEST_VRECPS(, float, f, 32, 2);
115   TEST_VRECPS(q, float, f, 32, 4);
116 
117   fprintf (ref_file, "\n%s output:\n", TEST_MSG " FP special (infinity, 0)");
118   DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
119   DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
120 }
121