blob: 4e355b9bcc5173eee52368569b6ad14d0287b235 [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 Lyonae97a862011-09-23 11:24:43 +020033#include <math.h>
Christophe Lyon073831a2011-01-24 17:37:40 +010034
35#define TEST_MSG "VRSQRTS/VRSQRTSQ"
36void exec_vrsqrts(void)
37{
38 int i;
39
40 /* Basic test: y=vrsqrts(x), then store the result. */
41#define TEST_VRSQRTS(Q, T1, T2, W, N) \
42 VECT_VAR(vector_res, T1, W, N) = \
43 vrsqrts##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 */
Christophe Lyonf2053672014-12-16 10:26:00 +010064 VDUP(vector, , float, f, 32, 2, 12.9f);
65 VDUP(vector, q, float, f, 32, 4, 9.1f);
Christophe Lyon073831a2011-01-24 17:37:40 +010066
Christophe Lyonf2053672014-12-16 10:26:00 +010067 VDUP(vector2, , float, f, 32, 2, 9.9f);
68 VDUP(vector2, q, float, f, 32, 4, 1.9f);
Christophe Lyon073831a2011-01-24 17:37:40 +010069
70 /* Apply the operator */
71 TEST_VRSQRTS(, float, f, 32, 2);
72 TEST_VRSQRTS(q, float, f, 32, 4);
73
74 fprintf (ref_file, "\n%s output:\n", TEST_MSG);
Christophe Lyonbf218262014-07-10 15:53:15 +020075 fprintf (gcc_tests_file, "\n%s output:\n", TEST_MSG);
Christophe Lyon073831a2011-01-24 17:37:40 +010076 DUMP_FP(TEST_MSG, float, 32, 2, PRIx32);
77 DUMP_FP(TEST_MSG, float, 32, 4, PRIx32);
Christophe Lyonae97a862011-09-23 11:24:43 +020078
79
80 /* Test FP variants with special input values (NaN) */
Christophe Lyonf2053672014-12-16 10:26:00 +010081 VDUP(vector, , float, f, 32, 2, NAN);
82 VDUP(vector2, q, float, f, 32, 4, NAN);
Christophe Lyonae97a862011-09-23 11:24:43 +020083
84 /* Apply the operator */
85 TEST_VRSQRTS(, float, f, 32, 2);
86 TEST_VRSQRTS(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) */
Christophe Lyonf2053672014-12-16 10:26:00 +010094 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 */
Christophe Lyonae97a862011-09-23 11:24:43 +020097
98 /* Apply the operator */
99 TEST_VRSQRTS(, float, f, 32, 2);
100 TEST_VRSQRTS(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) */
Christophe Lyonf2053672014-12-16 10:26:00 +0100108 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);
Christophe Lyonae97a862011-09-23 11:24:43 +0200112
113 /* Apply the operator */
114 TEST_VRSQRTS(, float, f, 32, 2);
115 TEST_VRSQRTS(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);
Christophe Lyon073831a2011-01-24 17:37:40 +0100120}