blob: 88ae2a517139fa27b4bb45b7daf76d00617400c5 [file] [log] [blame]
Matt Wala89a7c2b2014-07-22 10:55:30 -07001//===- subzero/crosstest/test_arith_main.cpp - Driver for tests -----------===//
2//
3// The Subzero Code Generator
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Driver for crosstesting arithmetic operations
11//
12//===----------------------------------------------------------------------===//
13
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070014/* crosstest.py --test=test_arith.cpp --test=test_arith_frem.ll \
Jan Voungf37fbbe2014-07-09 16:13:13 -070015 --test=test_arith_sqrt.ll --driver=test_arith_main.cpp \
16 --prefix=Subzero_ --output=test_arith */
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070017
18#include <stdint.h>
19
20#include <cfloat>
Antonio Maioranoca8a16e2020-11-10 16:56:20 -050021#include <climits> // CHAR_BIT
Matt Wala7fa22d82014-07-17 12:41:31 -070022#include <cmath> // fmodf
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070023#include <cstring> // memcmp
24#include <iostream>
Antonio Maioranoca8a16e2020-11-10 16:56:20 -050025#include <limits>
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070026
27// Include test_arith.h twice - once normally, and once within the
28// Subzero_ namespace, corresponding to the llc and Subzero translated
29// object files, respectively.
30#include "test_arith.h"
John Porto1d235422015-08-12 12:37:53 -070031
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070032namespace Subzero_ {
33#include "test_arith.h"
34}
35
Jim Stichnoth57a8aab2016-01-06 09:34:36 -080036#include "insertelement.h"
37#include "xdefs.h"
38
Matt Wala7fa22d82014-07-17 12:41:31 -070039template <class T> bool inputsMayTriggerException(T Value1, T Value2) {
40 // Avoid HW divide-by-zero exception.
41 if (Value2 == 0)
42 return true;
43 // Avoid HW overflow exception (on x86-32). TODO: adjust
44 // for other architecture.
45 if (Value1 == std::numeric_limits<T>::min() && Value2 == -1)
46 return true;
47 return false;
48}
49
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070050template <typename TypeUnsigned, typename TypeSigned>
51void testsInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
52 typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned);
53 typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned);
Matt Wala35ec3732014-07-18 16:32:16 -070054 volatile unsigned Values[] = INT_VALUE_ARRAY;
55 const static size_t NumValues = sizeof(Values) / sizeof(*Values);
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070056 static struct {
Jim Stichnoth7da431b2014-08-05 11:22:37 -070057 // For functions that operate on unsigned values, the
58 // FuncLlcSigned and FuncSzSigned fields are NULL. For functions
59 // that operate on signed values, the FuncLlcUnsigned and
60 // FuncSzUnsigned fields are NULL.
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070061 const char *Name;
Jim Stichnoth7da431b2014-08-05 11:22:37 -070062 FuncTypeUnsigned FuncLlcUnsigned;
63 FuncTypeUnsigned FuncSzUnsigned;
64 FuncTypeSigned FuncLlcSigned;
65 FuncTypeSigned FuncSzSigned;
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070066 bool ExcludeDivExceptions; // for divide related tests
67 } Funcs[] = {
Matt Walaafeaee42014-08-07 13:47:30 -070068#define X(inst, op, isdiv, isshift) \
Antonio Maioranoca8a16e2020-11-10 16:56:20 -050069 {STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv},
Jim Stichnothd9dc82e2015-03-03 17:06:33 -080070 UINTOP_TABLE
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070071#undef X
Matt Walaafeaee42014-08-07 13:47:30 -070072#define X(inst, op, isdiv, isshift) \
Antonio Maioranoca8a16e2020-11-10 16:56:20 -050073 {STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv},
Jim Stichnothd9dc82e2015-03-03 17:06:33 -080074 SINTOP_TABLE
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070075#undef X
John Porto98cc08c2015-11-24 12:30:01 -080076#define X(mult_by) \
Antonio Maioranoca8a16e2020-11-10 16:56:20 -050077 {"Mult-By-" STR(mult_by), \
78 testMultiplyBy##mult_by, \
79 Subzero_::testMultiplyBy##mult_by, \
80 NULL, \
81 NULL, \
82 false}, \
83 {"Mult-By-Neg-" STR(mult_by), \
84 testMultiplyByNeg##mult_by, \
85 Subzero_::testMultiplyByNeg##mult_by, \
86 NULL, \
87 NULL, \
88 false},
John Porto98cc08c2015-11-24 12:30:01 -080089 MULIMM_TABLE};
90#undef X
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -070091 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
92
93 if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) {
94 // This is the "normal" version of the loop nest, for 32-bit or
95 // narrower types.
96 for (size_t f = 0; f < NumFuncs; ++f) {
97 for (size_t i = 0; i < NumValues; ++i) {
98 for (size_t j = 0; j < NumValues; ++j) {
99 TypeUnsigned Value1 = Values[i];
100 TypeUnsigned Value2 = Values[j];
101 // Avoid HW divide-by-zero exception.
Matt Wala7fa22d82014-07-17 12:41:31 -0700102 if (Funcs[f].ExcludeDivExceptions &&
103 inputsMayTriggerException<TypeSigned>(Value1, Value2))
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700104 continue;
105 ++TotalTests;
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700106 TypeUnsigned ResultSz, ResultLlc;
107 if (Funcs[f].FuncSzUnsigned) {
108 ResultSz = Funcs[f].FuncSzUnsigned(Value1, Value2);
109 ResultLlc = Funcs[f].FuncLlcUnsigned(Value1, Value2);
110 } else {
111 ResultSz = Funcs[f].FuncSzSigned(Value1, Value2);
112 ResultLlc = Funcs[f].FuncLlcSigned(Value1, Value2);
113 }
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700114 if (ResultSz == ResultLlc) {
115 ++Passes;
116 } else {
117 ++Failures;
Matt Wala7fa22d82014-07-17 12:41:31 -0700118 std::cout << "test" << Funcs[f].Name
119 << (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1
120 << ", " << Value2 << "): sz=" << (unsigned)ResultSz
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700121 << " llc=" << (unsigned)ResultLlc << "\n";
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700122 }
123 }
124 }
125 }
126 } else {
127 // This is the 64-bit version. Test values are synthesized from
128 // the 32-bit values in Values[].
129 for (size_t f = 0; f < NumFuncs; ++f) {
130 for (size_t iLo = 0; iLo < NumValues; ++iLo) {
131 for (size_t iHi = 0; iHi < NumValues; ++iHi) {
132 for (size_t jLo = 0; jLo < NumValues; ++jLo) {
133 for (size_t jHi = 0; jHi < NumValues; ++jHi) {
134 TypeUnsigned Value1 =
135 (((TypeUnsigned)Values[iHi]) << 32) + Values[iLo];
136 TypeUnsigned Value2 =
137 (((TypeUnsigned)Values[jHi]) << 32) + Values[jLo];
Matt Wala7fa22d82014-07-17 12:41:31 -0700138 if (Funcs[f].ExcludeDivExceptions &&
139 inputsMayTriggerException<TypeSigned>(Value1, Value2))
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700140 continue;
141 ++TotalTests;
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700142 TypeUnsigned ResultSz, ResultLlc;
143 if (Funcs[f].FuncSzUnsigned) {
144 ResultSz = Funcs[f].FuncSzUnsigned(Value1, Value2);
145 ResultLlc = Funcs[f].FuncLlcUnsigned(Value1, Value2);
146 } else {
147 ResultSz = Funcs[f].FuncSzSigned(Value1, Value2);
148 ResultLlc = Funcs[f].FuncLlcSigned(Value1, Value2);
149 }
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700150 if (ResultSz == ResultLlc) {
151 ++Passes;
152 } else {
153 ++Failures;
154 std::cout << "test" << Funcs[f].Name
Matt Wala7fa22d82014-07-17 12:41:31 -0700155 << (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1
John Portoba6a67c2015-09-25 15:19:45 -0700156 << ", " << Value2 << "): sz=" << (uint64)ResultSz
157 << " llc=" << (uint64)ResultLlc << "\n";
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700158 }
159 }
160 }
161 }
162 }
163 }
164 }
165}
166
Matt Wala7fa22d82014-07-17 12:41:31 -0700167const static size_t MaxTestsPerFunc = 100000;
168
Matt Wala89a7c2b2014-07-22 10:55:30 -0700169template <typename TypeUnsignedLabel, typename TypeSignedLabel>
Matt Wala7fa22d82014-07-17 12:41:31 -0700170void testsVecInt(size_t &TotalTests, size_t &Passes, size_t &Failures) {
Matt Wala89a7c2b2014-07-22 10:55:30 -0700171 typedef typename Vectors<TypeUnsignedLabel>::Ty TypeUnsigned;
172 typedef typename Vectors<TypeSignedLabel>::Ty TypeSigned;
173 typedef typename Vectors<TypeUnsignedLabel>::ElementTy ElementTypeUnsigned;
174 typedef typename Vectors<TypeSignedLabel>::ElementTy ElementTypeSigned;
175
Matt Wala7fa22d82014-07-17 12:41:31 -0700176 typedef TypeUnsigned (*FuncTypeUnsigned)(TypeUnsigned, TypeUnsigned);
177 typedef TypeSigned (*FuncTypeSigned)(TypeSigned, TypeSigned);
Matt Wala35ec3732014-07-18 16:32:16 -0700178 volatile unsigned Values[] = INT_VALUE_ARRAY;
179 const static size_t NumValues = sizeof(Values) / sizeof(*Values);
Matt Wala7fa22d82014-07-17 12:41:31 -0700180 static struct {
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700181 // For functions that operate on unsigned values, the
182 // FuncLlcSigned and FuncSzSigned fields are NULL. For functions
183 // that operate on signed values, the FuncLlcUnsigned and
184 // FuncSzUnsigned fields are NULL.
Matt Wala7fa22d82014-07-17 12:41:31 -0700185 const char *Name;
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700186 FuncTypeUnsigned FuncLlcUnsigned;
187 FuncTypeUnsigned FuncSzUnsigned;
188 FuncTypeSigned FuncLlcSigned;
189 FuncTypeSigned FuncSzSigned;
Matt Wala7fa22d82014-07-17 12:41:31 -0700190 bool ExcludeDivExceptions; // for divide related tests
Matt Walaafeaee42014-08-07 13:47:30 -0700191 bool MaskShiftOperations; // for shift related tests
Matt Wala7fa22d82014-07-17 12:41:31 -0700192 } Funcs[] = {
Matt Walaafeaee42014-08-07 13:47:30 -0700193#define X(inst, op, isdiv, isshift) \
Antonio Maioranoca8a16e2020-11-10 16:56:20 -0500194 {STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv, isshift},
Jim Stichnothd9dc82e2015-03-03 17:06:33 -0800195 UINTOP_TABLE
Matt Wala7fa22d82014-07-17 12:41:31 -0700196#undef X
Matt Walaafeaee42014-08-07 13:47:30 -0700197#define X(inst, op, isdiv, isshift) \
Antonio Maioranoca8a16e2020-11-10 16:56:20 -0500198 {STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv, isshift},
Jim Stichnothd9dc82e2015-03-03 17:06:33 -0800199 SINTOP_TABLE
Matt Wala7fa22d82014-07-17 12:41:31 -0700200#undef X
Jim Stichnothd9dc82e2015-03-03 17:06:33 -0800201 };
Matt Wala7fa22d82014-07-17 12:41:31 -0700202 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
Matt Wala89a7c2b2014-07-22 10:55:30 -0700203 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements;
Matt Wala7fa22d82014-07-17 12:41:31 -0700204 for (size_t f = 0; f < NumFuncs; ++f) {
205 PRNG Index;
206 for (size_t i = 0; i < MaxTestsPerFunc; ++i) {
207 // Initialize the test vectors.
208 TypeUnsigned Value1, Value2;
Jim Stichnoth8ff4b282016-01-04 15:39:06 -0800209 for (size_t j = 0; j < NumElementsInType; ++j) {
Matt Wala35ec3732014-07-18 16:32:16 -0700210 ElementTypeUnsigned Element1 = Values[Index() % NumValues];
211 ElementTypeUnsigned Element2 = Values[Index() % NumValues];
Matt Wala7fa22d82014-07-17 12:41:31 -0700212 if (Funcs[f].ExcludeDivExceptions &&
213 inputsMayTriggerException<ElementTypeSigned>(Element1, Element2))
214 continue;
Matt Walaafeaee42014-08-07 13:47:30 -0700215 if (Funcs[f].MaskShiftOperations)
216 Element2 &= CHAR_BIT * sizeof(ElementTypeUnsigned) - 1;
Jim Stichnoth57a8aab2016-01-06 09:34:36 -0800217 setElement(Value1, j, Element1);
218 setElement(Value2, j, Element2);
Matt Wala7fa22d82014-07-17 12:41:31 -0700219 }
220 // Perform the test.
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700221 TypeUnsigned ResultSz, ResultLlc;
Matt Wala7fa22d82014-07-17 12:41:31 -0700222 ++TotalTests;
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700223 if (Funcs[f].FuncSzUnsigned) {
224 ResultSz = Funcs[f].FuncSzUnsigned(Value1, Value2);
225 ResultLlc = Funcs[f].FuncLlcUnsigned(Value1, Value2);
226 } else {
227 ResultSz = Funcs[f].FuncSzSigned(Value1, Value2);
228 ResultLlc = Funcs[f].FuncLlcSigned(Value1, Value2);
229 }
Matt Wala7fa22d82014-07-17 12:41:31 -0700230 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) {
231 ++Passes;
232 } else {
Matt Wala89a7c2b2014-07-22 10:55:30 -0700233 ++Failures;
Matt Wala7fa22d82014-07-17 12:41:31 -0700234 std::cout << "test" << Funcs[f].Name << "v" << NumElementsInType << "i"
Matt Wala89a7c2b2014-07-22 10:55:30 -0700235 << (CHAR_BIT * sizeof(ElementTypeUnsigned)) << "("
236 << vectAsString<TypeUnsignedLabel>(Value1) << ","
237 << vectAsString<TypeUnsignedLabel>(Value2)
238 << "): sz=" << vectAsString<TypeUnsignedLabel>(ResultSz)
239 << " llc=" << vectAsString<TypeUnsignedLabel>(ResultLlc)
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700240 << "\n";
Matt Wala7fa22d82014-07-17 12:41:31 -0700241 }
242 }
243 }
244}
245
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700246template <typename Type>
247void testsFp(size_t &TotalTests, size_t &Passes, size_t &Failures) {
248 static const Type NegInf = -1.0 / 0.0;
249 static const Type PosInf = 1.0 / 0.0;
250 static const Type Nan = 0.0 / 0.0;
Jan Voungf37fbbe2014-07-09 16:13:13 -0700251 static const Type NegNan = -0.0 / 0.0;
Matt Wala7fa22d82014-07-17 12:41:31 -0700252 volatile Type Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan);
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700253 const static size_t NumValues = sizeof(Values) / sizeof(*Values);
254 typedef Type (*FuncType)(Type, Type);
255 static struct {
256 const char *Name;
257 FuncType FuncLlc;
258 FuncType FuncSz;
259 } Funcs[] = {
260#define X(inst, op, func) \
Antonio Maioranoca8a16e2020-11-10 16:56:20 -0500261 {STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst},
Jim Stichnothd9dc82e2015-03-03 17:06:33 -0800262 FPOP_TABLE
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700263#undef X
Jim Stichnothd9dc82e2015-03-03 17:06:33 -0800264 };
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700265 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
266
267 for (size_t f = 0; f < NumFuncs; ++f) {
268 for (size_t i = 0; i < NumValues; ++i) {
269 for (size_t j = 0; j < NumValues; ++j) {
270 Type Value1 = Values[i];
271 Type Value2 = Values[j];
272 ++TotalTests;
273 Type ResultSz = Funcs[f].FuncSz(Value1, Value2);
274 Type ResultLlc = Funcs[f].FuncLlc(Value1, Value2);
275 // Compare results using memcmp() in case they are both NaN.
276 if (!memcmp(&ResultSz, &ResultLlc, sizeof(Type))) {
277 ++Passes;
278 } else {
279 ++Failures;
280 std::cout << std::fixed << "test" << Funcs[f].Name
Matt Wala7fa22d82014-07-17 12:41:31 -0700281 << (CHAR_BIT * sizeof(Type)) << "(" << Value1 << ", "
282 << Value2 << "): sz=" << ResultSz << " llc=" << ResultLlc
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700283 << "\n";
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700284 }
285 }
286 }
287 }
Jan Voungf37fbbe2014-07-09 16:13:13 -0700288 for (size_t i = 0; i < NumValues; ++i) {
289 Type Value = Values[i];
290 ++TotalTests;
291 Type ResultSz = Subzero_::mySqrt(Value);
292 Type ResultLlc = mySqrt(Value);
293 // Compare results using memcmp() in case they are both NaN.
294 if (!memcmp(&ResultSz, &ResultLlc, sizeof(Type))) {
295 ++Passes;
296 } else {
297 ++Failures;
Matt Wala7fa22d82014-07-17 12:41:31 -0700298 std::cout << std::fixed << "test_sqrt" << (CHAR_BIT * sizeof(Type)) << "("
299 << Value << "): sz=" << ResultSz << " llc=" << ResultLlc
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700300 << "\n";
Jan Voungf37fbbe2014-07-09 16:13:13 -0700301 }
Jim Stichnoth8c980d02015-03-19 13:01:50 -0700302 ++TotalTests;
303 ResultSz = Subzero_::myFabs(Value);
304 ResultLlc = myFabs(Value);
305 // Compare results using memcmp() in case they are both NaN.
306 if (!memcmp(&ResultSz, &ResultLlc, sizeof(Type))) {
307 ++Passes;
308 } else {
309 ++Failures;
310 std::cout << std::fixed << "test_fabs" << (CHAR_BIT * sizeof(Type)) << "("
311 << Value << "): sz=" << ResultSz << " llc=" << ResultLlc
312 << "\n";
313 }
Jan Voungf37fbbe2014-07-09 16:13:13 -0700314 }
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700315}
316
Matt Wala7fa22d82014-07-17 12:41:31 -0700317void testsVecFp(size_t &TotalTests, size_t &Passes, size_t &Failures) {
318 static const float NegInf = -1.0 / 0.0;
319 static const float PosInf = 1.0 / 0.0;
320 static const float Nan = 0.0 / 0.0;
321 static const float NegNan = -0.0 / 0.0;
322 volatile float Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan);
323 const static size_t NumValues = sizeof(Values) / sizeof(*Values);
324 typedef v4f32 (*FuncType)(v4f32, v4f32);
325 static struct {
326 const char *Name;
327 FuncType FuncLlc;
328 FuncType FuncSz;
329 } Funcs[] = {
330#define X(inst, op, func) \
Antonio Maioranoca8a16e2020-11-10 16:56:20 -0500331 {STR(inst), (FuncType)test##inst, (FuncType)Subzero_::test##inst},
Jim Stichnothd9dc82e2015-03-03 17:06:33 -0800332 FPOP_TABLE
Matt Wala7fa22d82014-07-17 12:41:31 -0700333#undef X
Jim Stichnothd9dc82e2015-03-03 17:06:33 -0800334 };
Matt Wala7fa22d82014-07-17 12:41:31 -0700335 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
336 const static size_t NumElementsInType = 4;
337 for (size_t f = 0; f < NumFuncs; ++f) {
338 PRNG Index;
339 for (size_t i = 0; i < MaxTestsPerFunc; ++i) {
340 // Initialize the test vectors.
341 v4f32 Value1, Value2;
342 for (size_t j = 0; j < NumElementsInType; ++j) {
Jim Stichnoth57a8aab2016-01-06 09:34:36 -0800343 setElement(Value1, j, Values[Index() % NumValues]);
344 setElement(Value2, j, Values[Index() % NumValues]);
Matt Wala7fa22d82014-07-17 12:41:31 -0700345 }
346 // Perform the test.
347 v4f32 ResultSz = Funcs[f].FuncSz(Value1, Value2);
348 v4f32 ResultLlc = Funcs[f].FuncLlc(Value1, Value2);
349 ++TotalTests;
350 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) {
351 ++Passes;
352 } else {
353 ++Failures;
Matt Wala89a7c2b2014-07-22 10:55:30 -0700354 std::cout << "test" << Funcs[f].Name << "v4f32"
355 << "(" << vectAsString<v4f32>(Value1) << ","
356 << vectAsString<v4f32>(Value2)
357 << "): sz=" << vectAsString<v4f32>(ResultSz) << " llc"
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700358 << vectAsString<v4f32>(ResultLlc) << "\n";
Matt Wala7fa22d82014-07-17 12:41:31 -0700359 }
Jim Stichnoth8c980d02015-03-19 13:01:50 -0700360 // Special case for unary fabs operation. Use Value1, ignore Value2.
361 ResultSz = Subzero_::myFabs(Value1);
362 ResultLlc = myFabs(Value1);
363 ++TotalTests;
364 if (!memcmp(&ResultSz, &ResultLlc, sizeof(ResultSz))) {
365 ++Passes;
366 } else {
367 ++Failures;
368 std::cout << "test_fabs_v4f32"
369 << "(" << vectAsString<v4f32>(Value1)
370 << "): sz=" << vectAsString<v4f32>(ResultSz) << " llc"
371 << vectAsString<v4f32>(ResultLlc) << "\n";
372 }
Matt Wala7fa22d82014-07-17 12:41:31 -0700373 }
374 }
375}
376
John Porto1d235422015-08-12 12:37:53 -0700377int main(int argc, char *argv[]) {
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700378 size_t TotalTests = 0;
379 size_t Passes = 0;
380 size_t Failures = 0;
381
Jim Stichnoth3ef786f2014-09-08 11:19:21 -0700382 testsInt<bool, bool>(TotalTests, Passes, Failures);
Jim Stichnoth7da431b2014-08-05 11:22:37 -0700383 testsInt<uint8_t, myint8_t>(TotalTests, Passes, Failures);
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700384 testsInt<uint16_t, int16_t>(TotalTests, Passes, Failures);
385 testsInt<uint32_t, int32_t>(TotalTests, Passes, Failures);
John Porto1d235422015-08-12 12:37:53 -0700386 testsInt<uint64, int64>(TotalTests, Passes, Failures);
Matt Wala89a7c2b2014-07-22 10:55:30 -0700387 testsVecInt<v4ui32, v4si32>(TotalTests, Passes, Failures);
388 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures);
389 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures);
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700390 testsFp<float>(TotalTests, Passes, Failures);
391 testsFp<double>(TotalTests, Passes, Failures);
Matt Wala7fa22d82014-07-17 12:41:31 -0700392 testsVecFp(TotalTests, Passes, Failures);
Jim Stichnoth5bc2b1d2014-05-22 13:38:48 -0700393
394 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
395 << " Failures=" << Failures << "\n";
396 return Failures;
397}