| OLD | NEW |
| 1 //===- subzero/crosstest/test_icmp_main.cpp - Driver for tests. -----------===// | 1 //===- subzero/crosstest/test_icmp_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 cross testing the icmp bitcode instruction | 10 // Driver for cross testing the icmp bitcode instruction |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 const char *Name; | 43 const char *Name; |
| 44 FuncTypeUnsigned FuncLlc; | 44 FuncTypeUnsigned FuncLlc; |
| 45 FuncTypeUnsigned FuncSz; | 45 FuncTypeUnsigned FuncSz; |
| 46 } Funcs[] = { | 46 } Funcs[] = { |
| 47 #define X(cmp, op) \ | 47 #define X(cmp, op) \ |
| 48 { \ | 48 { \ |
| 49 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \ | 49 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \ |
| 50 (FuncTypeUnsigned)Subzero_::icmp##cmp \ | 50 (FuncTypeUnsigned)Subzero_::icmp##cmp \ |
| 51 } \ | 51 } \ |
| 52 , | 52 , |
| 53 ICMP_U_TABLE | 53 ICMP_U_TABLE |
| 54 #undef X | 54 #undef X |
| 55 #define X(cmp, op) \ | 55 #define X(cmp, op) \ |
| 56 { \ | 56 { \ |
| 57 STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned) icmp##cmp, \ | 57 STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned)icmp##cmp, \ |
| 58 (FuncTypeUnsigned)(FuncTypeSigned) Subzero_::icmp##cmp \ | 58 (FuncTypeUnsigned)(FuncTypeSigned)Subzero_::icmp##cmp \ |
| 59 } \ | 59 } \ |
| 60 , | 60 , |
| 61 ICMP_S_TABLE | 61 ICMP_S_TABLE |
| 62 #undef X | 62 #undef X |
| 63 }; | 63 }; |
| 64 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 64 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
| 65 | 65 |
| 66 if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) { | 66 if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) { |
| 67 // This is the "normal" version of the loop nest, for 32-bit or | 67 // This is the "normal" version of the loop nest, for 32-bit or |
| 68 // narrower types. | 68 // narrower types. |
| 69 for (size_t f = 0; f < NumFuncs; ++f) { | 69 for (size_t f = 0; f < NumFuncs; ++f) { |
| 70 for (size_t i = 0; i < NumValues; ++i) { | 70 for (size_t i = 0; i < NumValues; ++i) { |
| 71 for (size_t j = 0; j < NumValues; ++j) { | 71 for (size_t j = 0; j < NumValues; ++j) { |
| 72 TypeUnsigned Value1 = Values[i]; | 72 TypeUnsigned Value1 = Values[i]; |
| 73 TypeUnsigned Value2 = Values[j]; | 73 TypeUnsigned Value2 = Values[j]; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 const char *Name; | 130 const char *Name; |
| 131 FuncTypeUnsigned FuncLlc; | 131 FuncTypeUnsigned FuncLlc; |
| 132 FuncTypeUnsigned FuncSz; | 132 FuncTypeUnsigned FuncSz; |
| 133 } Funcs[] = { | 133 } Funcs[] = { |
| 134 #define X(cmp, op) \ | 134 #define X(cmp, op) \ |
| 135 { \ | 135 { \ |
| 136 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \ | 136 STR(cmp), (FuncTypeUnsigned)icmp##cmp, \ |
| 137 (FuncTypeUnsigned)Subzero_::icmp##cmp \ | 137 (FuncTypeUnsigned)Subzero_::icmp##cmp \ |
| 138 } \ | 138 } \ |
| 139 , | 139 , |
| 140 ICMP_U_TABLE | 140 ICMP_U_TABLE |
| 141 #undef X | 141 #undef X |
| 142 #define X(cmp, op) \ | 142 #define X(cmp, op) \ |
| 143 { \ | 143 { \ |
| 144 STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned) icmp##cmp, \ | 144 STR(cmp), (FuncTypeUnsigned)(FuncTypeSigned)icmp##cmp, \ |
| 145 (FuncTypeUnsigned)(FuncTypeSigned) Subzero_::icmp##cmp \ | 145 (FuncTypeUnsigned)(FuncTypeSigned)Subzero_::icmp##cmp \ |
| 146 } \ | 146 } \ |
| 147 , | 147 , |
| 148 ICMP_S_TABLE | 148 ICMP_S_TABLE |
| 149 #undef X | 149 #undef X |
| 150 }; | 150 }; |
| 151 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 151 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
| 152 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements; | 152 const static size_t NumElementsInType = Vectors<TypeUnsigned>::NumElements; |
| 153 for (size_t f = 0; f < NumFuncs; ++f) { | 153 for (size_t f = 0; f < NumFuncs; ++f) { |
| 154 PRNG Index; | 154 PRNG Index; |
| 155 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { | 155 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { |
| 156 // Initialize the test vectors. | 156 // Initialize the test vectors. |
| 157 TypeUnsigned Value1, Value2; | 157 TypeUnsigned Value1, Value2; |
| 158 for (size_t j = 0; j < NumElementsInType;) { | 158 for (size_t j = 0; j < NumElementsInType;) { |
| 159 Value1[j] = Values[Index() % NumValues]; | 159 Value1[j] = Values[Index() % NumValues]; |
| 160 Value2[j] = Values[Index() % NumValues]; | 160 Value2[j] = Values[Index() % NumValues]; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 typedef typename Vectors<T>::Ty Ty; | 199 typedef typename Vectors<T>::Ty Ty; |
| 200 typedef Ty (*FuncType)(Ty, Ty); | 200 typedef Ty (*FuncType)(Ty, Ty); |
| 201 static struct { | 201 static struct { |
| 202 const char *Name; | 202 const char *Name; |
| 203 FuncType FuncLlc; | 203 FuncType FuncLlc; |
| 204 FuncType FuncSz; | 204 FuncType FuncSz; |
| 205 } Funcs[] = { | 205 } Funcs[] = { |
| 206 #define X(cmp, op) \ | 206 #define X(cmp, op) \ |
| 207 { STR(cmp), (FuncType)icmpi1##cmp, (FuncType)Subzero_::icmpi1##cmp } \ | 207 { STR(cmp), (FuncType)icmpi1##cmp, (FuncType)Subzero_::icmpi1##cmp } \ |
| 208 , | 208 , |
| 209 ICMP_U_TABLE ICMP_S_TABLE}; | 209 ICMP_U_TABLE ICMP_S_TABLE}; |
| 210 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); | 210 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
| 211 const static size_t NumElements = Vectors<T>::NumElements; | 211 const static size_t NumElements = Vectors<T>::NumElements; |
| 212 const static size_t MAX_NUMBER_OF_ELEMENTS_FOR_EXHAUSTIVE_TESTING = 8; | 212 const static size_t MAX_NUMBER_OF_ELEMENTS_FOR_EXHAUSTIVE_TESTING = 8; |
| 213 | 213 |
| 214 // Check if the type is small enough to try all possible input pairs. | 214 // Check if the type is small enough to try all possible input pairs. |
| 215 if (NumElements <= MAX_NUMBER_OF_ELEMENTS_FOR_EXHAUSTIVE_TESTING) { | 215 if (NumElements <= MAX_NUMBER_OF_ELEMENTS_FOR_EXHAUSTIVE_TESTING) { |
| 216 for (size_t f = 0; f < NumFuncs; ++f) { | 216 for (size_t f = 0; f < NumFuncs; ++f) { |
| 217 Ty Value1, Value2; | 217 Ty Value1, Value2; |
| 218 memset(&Value1, 0, sizeof(Value1)); | 218 memset(&Value1, 0, sizeof(Value1)); |
| 219 for (bool IsValue1Done = false; !IsValue1Done; | 219 for (bool IsValue1Done = false; !IsValue1Done; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); | 278 testsVecInt<v8ui16, v8si16>(TotalTests, Passes, Failures); |
| 279 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); | 279 testsVecInt<v16ui8, v16si8>(TotalTests, Passes, Failures); |
| 280 testsVecI1<v4i1>(TotalTests, Passes, Failures); | 280 testsVecI1<v4i1>(TotalTests, Passes, Failures); |
| 281 testsVecI1<v8i1>(TotalTests, Passes, Failures); | 281 testsVecI1<v8i1>(TotalTests, Passes, Failures); |
| 282 testsVecI1<v16i1>(TotalTests, Passes, Failures); | 282 testsVecI1<v16i1>(TotalTests, Passes, Failures); |
| 283 | 283 |
| 284 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes | 284 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes |
| 285 << " Failures=" << Failures << "\n"; | 285 << " Failures=" << Failures << "\n"; |
| 286 return Failures; | 286 return Failures; |
| 287 } | 287 } |
| OLD | NEW |