Index: crosstest/test_arith_main.cpp |
diff --git a/crosstest/test_arith_main.cpp b/crosstest/test_arith_main.cpp |
index 84bc6b72ebd6827d4df56e5cf4164e5f2791de4b..6d4ca824b852be6b0c629da2115013a60fd38d05 100644 |
--- a/crosstest/test_arith_main.cpp |
+++ b/crosstest/test_arith_main.cpp |
@@ -11,8 +11,9 @@ |
// |
//===----------------------------------------------------------------------===// |
-/* crosstest.py --test=test_arith.cpp --test=test_arith_frem.ll \ |
- --test=test_arith_sqrt.ll --driver=test_arith_main.cpp \ |
+/* crosstest.py --test=test_arith.cpp --test=test_arith_bool.ll \ |
+ --test=test_arith_frem.ll --test=test_arith_sqrt.ll \ |
+ --driver=test_arith_main.cpp \ |
--prefix=Subzero_ --output=test_arith */ |
#include <stdint.h> |
@@ -32,7 +33,12 @@ namespace Subzero_ { |
#include "test_arith.h" |
} |
-template <class T> bool inputsMayTriggerException(T Value1, T Value2) { |
+template <class T> |
+bool inputsMayTriggerException(T Value1, T Value2, bool IsReallyBool = false) { |
+ if (IsReallyBool) { |
+ Value1 &= 1; |
+ Value2 &= 1; |
+ } |
// Avoid HW divide-by-zero exception. |
if (Value2 == 0) |
return true; |
@@ -60,18 +66,22 @@ void testsInt(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
FuncTypeSigned FuncLlcSigned; |
FuncTypeSigned FuncSzSigned; |
bool ExcludeDivExceptions; // for divide related tests |
+ bool IsReallyBool; |
} Funcs[] = { |
#define X(inst, op, isdiv, isshift) \ |
- { STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv } \ |
- , |
+ { \ |
+ "Bool" STR(inst), testBool##inst, Subzero_::testBool##inst, NULL, NULL, \ |
+ isdiv, true \ |
+ } \ |
+ , { STR(inst), test##inst, Subzero_::test##inst, NULL, NULL, isdiv, false }, |
UINTOP_TABLE |
#undef X |
#define X(inst, op, isdiv, isshift) \ |
- { STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv } \ |
+ { STR(inst), NULL, NULL, test##inst, Subzero_::test##inst, isdiv, false } \ |
, |
- SINTOP_TABLE |
+ SINTOP_TABLE |
#undef X |
- }; |
+ }; |
const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs); |
if (sizeof(TypeUnsigned) <= sizeof(uint32_t)) { |
@@ -84,13 +94,14 @@ void testsInt(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
TypeUnsigned Value2 = Values[j]; |
// Avoid HW divide-by-zero exception. |
if (Funcs[f].ExcludeDivExceptions && |
- inputsMayTriggerException<TypeSigned>(Value1, Value2)) |
+ inputsMayTriggerException<TypeSigned>(Value1, Value2, |
+ Funcs[f].IsReallyBool)) |
continue; |
++TotalTests; |
TypeUnsigned ResultSz, ResultLlc; |
if (Funcs[f].FuncSzUnsigned) { |
- ResultSz = Funcs[f].FuncSzUnsigned(Value1, Value2); |
ResultLlc = Funcs[f].FuncLlcUnsigned(Value1, Value2); |
+ ResultSz = Funcs[f].FuncSzUnsigned(Value1, Value2); |
} else { |
ResultSz = Funcs[f].FuncSzSigned(Value1, Value2); |
ResultLlc = Funcs[f].FuncLlcSigned(Value1, Value2); |
@@ -100,8 +111,9 @@ void testsInt(size_t &TotalTests, size_t &Passes, size_t &Failures) { |
} else { |
++Failures; |
std::cout << "test" << Funcs[f].Name |
- << (CHAR_BIT * sizeof(TypeUnsigned)) << "(" << Value1 |
- << ", " << Value2 << "): sz=" << (unsigned)ResultSz |
+ << (CHAR_BIT * sizeof(TypeUnsigned)) << "(" |
+ << (unsigned)Value1 << ", " << (unsigned)Value2 |
+ << "): sz=" << (unsigned)ResultSz |
<< " llc=" << (unsigned)ResultLlc << "\n"; |
} |
} |