Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 1 | /* |
| 2 | |
Christophe Lyon | 80902f6 | 2013-03-29 16:26:42 +0100 | [diff] [blame] | 3 | Copyright (c) 2009, 2010, 2011, 2013 STMicroelectronics |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 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 | |
Christophe Lyon | 1775be0 | 2014-07-10 13:46:54 +0200 | [diff] [blame] | 26 | #if defined(__arm__) || defined(__aarch64__) |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 27 | #include <arm_neon.h> |
| 28 | #else |
Christophe Lyon | 0dab5f7 | 2011-07-19 17:14:09 +0200 | [diff] [blame] | 29 | #include "stm-arm-neon.h" |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 30 | #endif |
| 31 | |
| 32 | #include "stm-arm-neon-ref.h" |
Christophe Lyon | c8aa0f6 | 2011-09-26 18:00:27 +0200 | [diff] [blame] | 33 | #include <math.h> |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 34 | |
| 35 | |
| 36 | #define FNNAME1(NAME) void exec_ ## NAME (void) |
| 37 | #define FNNAME(NAME) FNNAME1(NAME) |
| 38 | |
| 39 | FNNAME (INSN_NAME) |
| 40 | { |
| 41 | int i; |
| 42 | |
| 43 | /* Basic test: y=vcomp(x,x), then store the result. */ |
| 44 | #define TEST_VCOMP1(INSN, Q, T1, T2, T3, W, N) \ |
| 45 | VECT_VAR(vector_res, T3, W, N) = \ |
| 46 | INSN##Q##_##T2##W(VECT_VAR(vector, T1, W, N), \ |
| 47 | VECT_VAR(vector2, T1, W, N)); \ |
| 48 | vst1##Q##_u##W(VECT_VAR(result, T3, W, N), VECT_VAR(vector_res, T3, W, N)) |
| 49 | |
| 50 | #define TEST_VCOMP(INSN, Q, T1, T2, T3, W, N) \ |
| 51 | TEST_VCOMP1(INSN, Q, T1, T2, T3, W, N) |
| 52 | |
| 53 | /* With ARM RVCT, we need to declare variables before any executable |
| 54 | statement */ |
| 55 | /* No need for 64 bits elements */ |
| 56 | DECL_VARIABLE(vector, int, 8, 8); |
| 57 | DECL_VARIABLE(vector, int, 16, 4); |
| 58 | DECL_VARIABLE(vector, int, 32, 2); |
| 59 | DECL_VARIABLE(vector, uint, 8, 8); |
| 60 | DECL_VARIABLE(vector, uint, 16, 4); |
| 61 | DECL_VARIABLE(vector, uint, 32, 2); |
| 62 | DECL_VARIABLE(vector, float, 32, 2); |
| 63 | DECL_VARIABLE(vector, int, 8, 16); |
| 64 | DECL_VARIABLE(vector, int, 16, 8); |
| 65 | DECL_VARIABLE(vector, int, 32, 4); |
| 66 | DECL_VARIABLE(vector, uint, 8, 16); |
| 67 | DECL_VARIABLE(vector, uint, 16, 8); |
| 68 | DECL_VARIABLE(vector, uint, 32, 4); |
| 69 | DECL_VARIABLE(vector, float, 32, 4); |
| 70 | |
| 71 | DECL_VARIABLE(vector2, int, 8, 8); |
| 72 | DECL_VARIABLE(vector2, int, 16, 4); |
| 73 | DECL_VARIABLE(vector2, int, 32, 2); |
| 74 | DECL_VARIABLE(vector2, uint, 8, 8); |
| 75 | DECL_VARIABLE(vector2, uint, 16, 4); |
| 76 | DECL_VARIABLE(vector2, uint, 32, 2); |
| 77 | DECL_VARIABLE(vector2, float, 32, 2); |
| 78 | DECL_VARIABLE(vector2, int, 8, 16); |
| 79 | DECL_VARIABLE(vector2, int, 16, 8); |
| 80 | DECL_VARIABLE(vector2, int, 32, 4); |
| 81 | DECL_VARIABLE(vector2, uint, 8, 16); |
| 82 | DECL_VARIABLE(vector2, uint, 16, 8); |
| 83 | DECL_VARIABLE(vector2, uint, 32, 4); |
| 84 | DECL_VARIABLE(vector2, float, 32, 4); |
| 85 | |
| 86 | DECL_VARIABLE(vector_res, uint, 8, 8); |
| 87 | DECL_VARIABLE(vector_res, uint, 16, 4); |
| 88 | DECL_VARIABLE(vector_res, uint, 32, 2); |
| 89 | DECL_VARIABLE(vector_res, uint, 8, 16); |
| 90 | DECL_VARIABLE(vector_res, uint, 16, 8); |
| 91 | DECL_VARIABLE(vector_res, uint, 32, 4); |
| 92 | |
| 93 | clean_results (); |
| 94 | |
| 95 | /* There is no 64 bits variant, we can't use the generic initializer */ |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 96 | VLOAD(vector, buffer, , int, s, 8, 8); |
| 97 | VLOAD(vector, buffer, , int, s, 16, 4); |
| 98 | VLOAD(vector, buffer, , int, s, 32, 2); |
| 99 | VLOAD(vector, buffer, , uint, u, 8, 8); |
| 100 | VLOAD(vector, buffer, , uint, u, 16, 4); |
| 101 | VLOAD(vector, buffer, , uint, u, 32, 2); |
| 102 | VLOAD(vector, buffer, , float, f, 32, 2); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 103 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 104 | VLOAD(vector, buffer, q, int, s, 8, 16); |
| 105 | VLOAD(vector, buffer, q, int, s, 16, 8); |
| 106 | VLOAD(vector, buffer, q, int, s, 32, 4); |
| 107 | VLOAD(vector, buffer, q, uint, u, 8, 16); |
| 108 | VLOAD(vector, buffer, q, uint, u, 16, 8); |
| 109 | VLOAD(vector, buffer, q, uint, u, 32, 4); |
| 110 | VLOAD(vector, buffer, q, float, f, 32, 4); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 111 | |
| 112 | /* Choose init value arbitrarily, will be used for vector |
| 113 | comparison */ |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 114 | VDUP(vector2, , int, s, 8, 8, -10); |
| 115 | VDUP(vector2, , int, s, 16, 4, -14); |
| 116 | VDUP(vector2, , int, s, 32, 2, -16); |
| 117 | VDUP(vector2, , uint, u, 8, 8, 0xF3); |
| 118 | VDUP(vector2, , uint, u, 16, 4, 0xFFF2); |
| 119 | VDUP(vector2, , uint, u, 32, 2, 0xFFFFFFF1); |
| 120 | VDUP(vector2, , float, f, 32, 2, -15.0f); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 121 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 122 | VDUP(vector2, q, int, s, 8, 16, -4); |
| 123 | VDUP(vector2, q, int, s, 16, 8, -10); |
| 124 | VDUP(vector2, q, int, s, 32, 4, -14); |
| 125 | VDUP(vector2, q, uint, u, 8, 16, 0xF4); |
| 126 | VDUP(vector2, q, uint, u, 16, 8, 0xFFF6); |
| 127 | VDUP(vector2, q, uint, u, 32, 4, 0xFFFFFFF2); |
| 128 | VDUP(vector2, q, float, f, 32, 4, -14.0f); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 129 | |
| 130 | /* The same result buffers are used multiple times, so output them |
| 131 | before overwriting them */ |
| 132 | fprintf(ref_file, "\n%s output:\n", TEST_MSG); |
Christophe Lyon | bf21826 | 2014-07-10 15:53:15 +0200 | [diff] [blame] | 133 | fprintf(gcc_tests_file, "\n%s output:\n", TEST_MSG); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 134 | TEST_VCOMP(INSN_NAME, , int, s, uint, 8, 8); |
| 135 | TEST_VCOMP(INSN_NAME, , int, s, uint, 16, 4); |
| 136 | TEST_VCOMP(INSN_NAME, , int, s, uint, 32, 2); |
| 137 | DUMP(TEST_MSG, uint, 8, 8, PRIx8); |
| 138 | DUMP(TEST_MSG, uint, 16, 4, PRIx16); |
| 139 | DUMP(TEST_MSG, uint, 32, 2, PRIx32); |
| 140 | |
| 141 | TEST_VCOMP(INSN_NAME, , uint, u, uint, 8, 8); |
| 142 | TEST_VCOMP(INSN_NAME, , uint, u, uint, 16, 4); |
| 143 | TEST_VCOMP(INSN_NAME, , uint, u, uint, 32, 2); |
| 144 | DUMP(TEST_MSG, uint, 8, 8, PRIx8); |
| 145 | DUMP(TEST_MSG, uint, 16, 4, PRIx16); |
| 146 | DUMP(TEST_MSG, uint, 32, 2, PRIx32); |
| 147 | |
| 148 | TEST_VCOMP(INSN_NAME, q, int, s, uint, 8, 16); |
| 149 | TEST_VCOMP(INSN_NAME, q, int, s, uint, 16, 8); |
| 150 | TEST_VCOMP(INSN_NAME, q, int, s, uint, 32, 4); |
| 151 | DUMP(TEST_MSG, uint, 8, 16, PRIx8); |
| 152 | DUMP(TEST_MSG, uint, 16, 8, PRIx16); |
| 153 | DUMP(TEST_MSG, uint, 32, 4, PRIx32); |
| 154 | |
| 155 | TEST_VCOMP(INSN_NAME, q, uint, u, uint, 8, 16); |
| 156 | TEST_VCOMP(INSN_NAME, q, uint, u, uint, 16, 8); |
| 157 | TEST_VCOMP(INSN_NAME, q, uint, u, uint, 32, 4); |
| 158 | DUMP(TEST_MSG, uint, 8, 16, PRIx8); |
| 159 | DUMP(TEST_MSG, uint, 16, 8, PRIx16); |
| 160 | DUMP(TEST_MSG, uint, 32, 4, PRIx32); |
| 161 | |
| 162 | TEST_VCOMP(INSN_NAME, , float, f, uint, 32, 2); |
| 163 | DUMP(TEST_MSG, uint, 32, 2, PRIx32); |
| 164 | |
| 165 | TEST_VCOMP(INSN_NAME, q, float, f, uint, 32, 4); |
| 166 | DUMP(TEST_MSG, uint, 32, 4, PRIx32); |
| 167 | |
| 168 | /* Extra tests to have 100% coverage on all the variants */ |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 169 | VDUP(vector2, , uint, u, 32, 2, 0xFFFFFFF0); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 170 | TEST_VCOMP(INSN_NAME, , uint, u, uint, 32, 2); |
| 171 | DUMP(TEST_MSG, uint, 32, 2, PRIx32); |
| 172 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 173 | VDUP(vector2, , int, s, 32, 2, -15); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 174 | TEST_VCOMP(INSN_NAME, , int, s, uint, 32, 2); |
| 175 | DUMP(TEST_MSG, uint, 32, 2, PRIx32); |
| 176 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 177 | VDUP(vector2, , float, f, 32, 2, -16.0f); |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 178 | TEST_VCOMP(INSN_NAME, , float, f, uint, 32, 2); |
| 179 | DUMP(TEST_MSG, uint, 32, 2, PRIx32); |
Christophe Lyon | c8aa0f6 | 2011-09-26 18:00:27 +0200 | [diff] [blame] | 180 | |
| 181 | |
| 182 | /* Extra FP tests with special values (NaN, ....) */ |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 183 | VDUP(vector, , float, f, 32, 2, 1.0); |
| 184 | VDUP(vector2, , float, f, 32, 2, NAN); |
Christophe Lyon | c8aa0f6 | 2011-09-26 18:00:27 +0200 | [diff] [blame] | 185 | TEST_VCOMP(INSN_NAME, , float, f, uint, 32, 2); |
Christophe Lyon | 269df92 | 2011-10-17 15:53:53 +0200 | [diff] [blame] | 186 | DUMP(TEST_MSG " FP special (NaN)", uint, 32, 2, PRIx32); |
| 187 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 188 | VDUP(vector, , float, f, 32, 2, 1.0); |
| 189 | VDUP(vector2, , float, f, 32, 2, -NAN); |
Christophe Lyon | 269df92 | 2011-10-17 15:53:53 +0200 | [diff] [blame] | 190 | TEST_VCOMP(INSN_NAME, , float, f, uint, 32, 2); |
| 191 | DUMP(TEST_MSG " FP special (-NaN)", uint, 32, 2, PRIx32); |
Christophe Lyon | c8aa0f6 | 2011-09-26 18:00:27 +0200 | [diff] [blame] | 192 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 193 | VDUP(vector, , float, f, 32, 2, NAN); |
| 194 | VDUP(vector2, , float, f, 32, 2, 1.0); |
Christophe Lyon | c8aa0f6 | 2011-09-26 18:00:27 +0200 | [diff] [blame] | 195 | TEST_VCOMP(INSN_NAME, , float, f, uint, 32, 2); |
Christophe Lyon | 269df92 | 2011-10-17 15:53:53 +0200 | [diff] [blame] | 196 | DUMP(TEST_MSG " FP special (NaN)", uint, 32, 2, PRIx32); |
Christophe Lyon | c8aa0f6 | 2011-09-26 18:00:27 +0200 | [diff] [blame] | 197 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 198 | VDUP(vector, , float, f, 32, 2, 1.0); |
| 199 | VDUP(vector2, , float, f, 32, 2, HUGE_VALF); |
Christophe Lyon | c8aa0f6 | 2011-09-26 18:00:27 +0200 | [diff] [blame] | 200 | TEST_VCOMP(INSN_NAME, , float, f, uint, 32, 2); |
| 201 | DUMP(TEST_MSG " FP special (inf)", uint, 32, 2, PRIx32); |
| 202 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 203 | VDUP(vector, , float, f, 32, 2, 1.0); |
| 204 | VDUP(vector2, , float, f, 32, 2, -HUGE_VALF); |
Christophe Lyon | 269df92 | 2011-10-17 15:53:53 +0200 | [diff] [blame] | 205 | TEST_VCOMP(INSN_NAME, , float, f, uint, 32, 2); |
| 206 | DUMP(TEST_MSG " FP special (-inf)", uint, 32, 2, PRIx32); |
| 207 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 208 | VDUP(vector, , float, f, 32, 2, HUGE_VALF); |
| 209 | VDUP(vector2, , float, f, 32, 2, 1.0); |
Christophe Lyon | c8aa0f6 | 2011-09-26 18:00:27 +0200 | [diff] [blame] | 210 | TEST_VCOMP(INSN_NAME, , float, f, uint, 32, 2); |
| 211 | DUMP(TEST_MSG " FP special (inf)", uint, 32, 2, PRIx32); |
| 212 | |
Christophe Lyon | f205367 | 2014-12-16 10:26:00 +0100 | [diff] [blame] | 213 | VDUP(vector, , float, f, 32, 2, -0.0); |
| 214 | VDUP(vector2, , float, f, 32, 2, 0.0); |
Christophe Lyon | c8aa0f6 | 2011-09-26 18:00:27 +0200 | [diff] [blame] | 215 | TEST_VCOMP(INSN_NAME, , float, f, uint, 32, 2); |
| 216 | DUMP(TEST_MSG " FP special (-0.0)", uint, 32, 2, PRIx32); |
Christophe Lyon | 80902f6 | 2013-03-29 16:26:42 +0100 | [diff] [blame] | 217 | |
| 218 | #ifdef EXTRA_TESTS |
| 219 | EXTRA_TESTS(); |
| 220 | #endif |
Christophe Lyon | 073831a | 2011-01-24 17:37:40 +0100 | [diff] [blame] | 221 | } |