Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: crosstest/test_arith_main.cpp

Issue 443203003: Subzero: Use scalar arithmetic when no vector instruction exists. (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: TODO(stichnot) Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « crosstest/test_arith.def ('k') | src/IceInstX8632.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/crosstest/test_arith_main.cpp - Driver for tests -----------===// 1 //===- subzero/crosstest/test_arith_main.cpp - Driver for tests -----------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // Driver for crosstesting arithmetic operations 10 // Driver for crosstesting arithmetic operations
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // FuncLlcSigned and FuncSzSigned fields are NULL. For functions 54 // FuncLlcSigned and FuncSzSigned fields are NULL. For functions
55 // that operate on signed values, the FuncLlcUnsigned and 55 // that operate on signed values, the FuncLlcUnsigned and
56 // FuncSzUnsigned fields are NULL. 56 // FuncSzUnsigned fields are NULL.
57 const char *Name; 57 const char *Name;
58 FuncTypeUnsigned FuncLlcUnsigned; 58 FuncTypeUnsigned FuncLlcUnsigned;
59 FuncTypeUnsigned FuncSzUnsigned; 59 FuncTypeUnsigned FuncSzUnsigned;
60 FuncTypeSigned FuncLlcSigned; 60 FuncTypeSigned FuncLlcSigned;
61 FuncTypeSigned FuncSzSigned; 61 FuncTypeSigned FuncSzSigned;
62 bool ExcludeDivExceptions; // for divide related tests 62 bool ExcludeDivExceptions; // for divide related tests
63 } Funcs[] = { 63 } Funcs[] = {
64 #define X(inst, op, isdiv) \ 64 #define X(inst, op, isdiv, isshift) \
65 { STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv } \ 65 { STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv } \
66 , 66 ,
67 UINTOP_TABLE 67 UINTOP_TABLE
68 #undef X 68 #undef X
69 #define X(inst, op, isdiv) \ 69 #define X(inst, op, isdiv, isshift) \
70 { STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv } \ 70 { STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv } \
71 , 71 ,
72 SINTOP_TABLE 72 SINTOP_TABLE
73 #undef X 73 #undef X
74 }; 74 };
75 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); 75 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
76 76
77 if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) { 77 if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) {
78 // This is the "normal" version of the loop nest, for 32-bit or 78 // This is the "normal" version of the loop nest, for 32-bit or
79 // narrower types. 79 // narrower types.
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 // For functions that operate on unsigned values, the 165 // For functions that operate on unsigned values, the
166 // FuncLlcSigned and FuncSzSigned fields are NULL. For functions 166 // FuncLlcSigned and FuncSzSigned fields are NULL. For functions
167 // that operate on signed values, the FuncLlcUnsigned and 167 // that operate on signed values, the FuncLlcUnsigned and
168 // FuncSzUnsigned fields are NULL. 168 // FuncSzUnsigned fields are NULL.
169 const char *Name; 169 const char *Name;
170 FuncTypeUnsigned FuncLlcUnsigned; 170 FuncTypeUnsigned FuncLlcUnsigned;
171 FuncTypeUnsigned FuncSzUnsigned; 171 FuncTypeUnsigned FuncSzUnsigned;
172 FuncTypeSigned FuncLlcSigned; 172 FuncTypeSigned FuncLlcSigned;
173 FuncTypeSigned FuncSzSigned; 173 FuncTypeSigned FuncSzSigned;
174 bool ExcludeDivExceptions; // for divide related tests 174 bool ExcludeDivExceptions; // for divide related tests
175 bool MaskShiftOperations; // for shift related tests
175 } Funcs[] = { 176 } Funcs[] = {
176 #define X(inst, op, isdiv) \ 177 #define X(inst, op, isdiv, isshift) \
177 { \ 178 { \
178 STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv \ 179 STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv, isshift \
179 } \ 180 } \
180 , 181 ,
181 UINTOP_TABLE 182 UINTOP_TABLE
182 #undef X 183 #undef X
183 #define X(inst, op, isdiv) \ 184 #define X(inst, op, isdiv, isshift) \
184 { \ 185 { \
185 STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv \ 186 STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv, isshift \
186 } \ 187 } \
187 , 188 ,
188 SINTOP_TABLE 189 SINTOP_TABLE
189 #undef X 190 #undef X
190 }; 191 };
191 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); 192 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
192 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements; 193 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements;
193 for (size_t f = 0; f < NumFuncs; ++f) { 194 for (size_t f = 0; f < NumFuncs; ++f) {
194 PRNG Index; 195 PRNG Index;
195 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { 196 for (size_t i = 0; i < MaxTestsPerFunc; ++i) {
196 // Initialize the test vectors. 197 // Initialize the test vectors.
197 TypeUnsigned Value1, Value2; 198 TypeUnsigned Value1, Value2;
198 for (size_t j = 0; j < NumElementsInType;) { 199 for (size_t j = 0; j < NumElementsInType;) {
199 ElementTypeUnsigned Element1 = Values[Index() % NumValues]; 200 ElementTypeUnsigned Element1 = Values[Index() % NumValues];
200 ElementTypeUnsigned Element2 = Values[Index() % NumValues]; 201 ElementTypeUnsigned Element2 = Values[Index() % NumValues];
201 if (Funcs[f].ExcludeDivExceptions && 202 if (Funcs[f].ExcludeDivExceptions &&
202 inputsMayTriggerException<ElementTypeSigned>(Element1, Element2)) 203 inputsMayTriggerException<ElementTypeSigned>(Element1, Element2))
203 continue; 204 continue;
205 if (Funcs[f].MaskShiftOperations)
206 Element2 &= CHAR_BIT * sizeof(ElementTypeUnsigned) - 1;
204 Value1[j] = Element1; 207 Value1[j] = Element1;
205 Value2[j] = Element2; 208 Value2[j] = Element2;
206 ++j; 209 ++j;
207 } 210 }
208 // Perform the test. 211 // Perform the test.
209 TypeUnsigned ResultSz, ResultLlc; 212 TypeUnsigned ResultSz, ResultLlc;
210 ++TotalTests; 213 ++TotalTests;
211 if (Funcs[f].FuncSzUnsigned) { 214 if (Funcs[f].FuncSzUnsigned) {
212 ResultSz = Funcs[f].FuncSzUnsigned(Value1, Value2); 215 ResultSz = Funcs[f].FuncSzUnsigned(Value1, Value2);
213 ResultLlc = Funcs[f].FuncLlcUnsigned(Value1, Value2); 216 ResultLlc = Funcs[f].FuncLlcUnsigned(Value1, Value2);
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); 356 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures);
354 testsFp<float>(TotalTests, Passes, Failures); 357 testsFp<float>(TotalTests, Passes, Failures);
355 testsFp<double>(TotalTests, Passes, Failures); 358 testsFp<double>(TotalTests, Passes, Failures);
356 testsVecFp(TotalTests, Passes, Failures); 359 testsVecFp(TotalTests, Passes, Failures);
357 360
358 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes 361 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
359 << " Failures=" << Failures << "\n"; 362 << " Failures=" << Failures << "\n";
360 return Failures; 363 return Failures;
361 } 364 }
362 365
363 extern "C" {
364 // Subzero helpers
365 v4si32 Sz_shl_v4i32(v4si32 a, v4si32 b) { return a << b; }
366 v4si32 Sz_ashr_v4i32(v4si32 a, v4si32 b) { return a >> b; }
367 v4ui32 Sz_lshr_v4i32(v4ui32 a, v4ui32 b) { return a >> b; }
368 v4si32 Sz_sdiv_v4i32(v4si32 a, v4si32 b) { return a / b; }
369 v4ui32 Sz_udiv_v4i32(v4ui32 a, v4ui32 b) { return a / b; }
370 v4si32 Sz_srem_v4i32(v4si32 a, v4si32 b) { return a % b; }
371 v4ui32 Sz_urem_v4i32(v4ui32 a, v4ui32 b) { return a % b; }
372
373 v8si16 Sz_shl_v8i16(v8si16 a, v8si16 b) { return a << b; }
374 v8si16 Sz_ashr_v8i16(v8si16 a, v8si16 b) { return a >> b; }
375 v8ui16 Sz_lshr_v8i16(v8ui16 a, v8ui16 b) { return a >> b; }
376 v8si16 Sz_sdiv_v8i16(v8si16 a, v8si16 b) { return a / b; }
377 v8ui16 Sz_udiv_v8i16(v8ui16 a, v8ui16 b) { return a / b; }
378 v8si16 Sz_srem_v8i16(v8si16 a, v8si16 b) { return a % b; }
379 v8ui16 Sz_urem_v8i16(v8ui16 a, v8ui16 b) { return a % b; }
380
381 v16ui8 Sz_mul_v16i8(v16ui8 a, v16ui8 b) { return a * b; }
382 v16si8 Sz_shl_v16i8(v16si8 a, v16si8 b) { return a << b; }
383 v16si8 Sz_ashr_v16i8(v16si8 a, v16si8 b) { return a >> b; }
384 v16ui8 Sz_lshr_v16i8(v16ui8 a, v16ui8 b) { return a >> b; }
385 v16si8 Sz_sdiv_v16i8(v16si8 a, v16si8 b) { return a / b; }
386 v16ui8 Sz_udiv_v16i8(v16ui8 a, v16ui8 b) { return a / b; }
387 v16si8 Sz_srem_v16i8(v16si8 a, v16si8 b) { return a % b; }
388 v16ui8 Sz_urem_v16i8(v16ui8 a, v16ui8 b) { return a % b; }
389
390 v4f32 Sz_frem_v4f32(v4f32 a, v4f32 b) {
391 v4f32 Result;
392 for (int i = 0; i < 4; ++i)
393 Result[i] = fmodf(a[i], b[i]);
394 return Result;
395 }
396 }
OLDNEW
« no previous file with comments | « crosstest/test_arith.def ('k') | src/IceInstX8632.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698