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

Side by Side Diff: crosstest/test_fcmp_main.cpp

Issue 265703002: Add Om1 lowering with no optimizations (Closed) Base URL: https://gerrit.chromium.org/gerrit/p/native_client/pnacl-subzero.git@master
Patch Set: Merge changed from Karl's committed CL Created 6 years, 7 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_fcmp.pnacl.ll ('k') | crosstest/test_icmp.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* crosstest.py --test=test_fcmp.pnacl.ll --driver=test_fcmp_main.cpp \
2 --prefix=Subzero_ --output=test_fcmp */
3
4 #include <cassert>
5 #include <cfloat>
6 #include <cmath>
7 #include <iostream>
8
9 #include "test_fcmp.def"
10
11 #define X(cmp) \
12 extern "C" bool fcmp##cmp##Float(float a, float b); \
13 extern "C" bool fcmp##cmp##Double(double a, double b); \
14 extern "C" bool Subzero_fcmp##cmp##Float(float a, float b); \
15 extern "C" bool Subzero_fcmp##cmp##Double(double a, double b);
16 FCMP_TABLE;
17 #undef X
18
19 int main(int argc, char **argv) {
20 static const double NegInf = -1.0 / 0.0;
21 static const double Zero = 0.0;
22 static const double Ten = 10.0;
23 static const double PosInf = 1.0 / 0.0;
24 static const double Nan = 0.0 / 0.0;
25 assert(std::fpclassify(NegInf) == FP_INFINITE);
26 assert(std::fpclassify(PosInf) == FP_INFINITE);
27 assert(std::fpclassify(Nan) == FP_NAN);
28 assert(NegInf < Zero);
29 assert(NegInf < PosInf);
30 assert(Zero < PosInf);
31
32 volatile double Values[] = { NegInf, Zero, DBL_MIN, FLT_MIN, Ten,
33 FLT_MAX, DBL_MAX, PosInf, Nan, };
34 const static size_t NumValues = sizeof(Values) / sizeof(*Values);
35
36 typedef bool (*FuncTypeFloat)(float, float);
37 typedef bool (*FuncTypeDouble)(double, double);
38 static struct {
39 const char *Name;
40 FuncTypeFloat FuncFloatSz;
41 FuncTypeFloat FuncFloatLlc;
42 FuncTypeDouble FuncDoubleSz;
43 FuncTypeDouble FuncDoubleLlc;
44 } Funcs[] = {
45 #define X(cmp) \
46 { \
47 "fcmp" STR(cmp), Subzero_fcmp##cmp##Float, fcmp##cmp##Float, \
48 Subzero_fcmp##cmp##Double, fcmp##cmp##Double \
49 } \
50 ,
51 FCMP_TABLE
52 #undef X
53 };
54 const static size_t NumFuncs = sizeof(Funcs) / sizeof(*Funcs);
55
56 bool ResultSz, ResultLlc;
57
58 size_t TotalTests = 0;
59 size_t Passes = 0;
60 size_t Failures = 0;
61
62 for (size_t f = 0; f < NumFuncs; ++f) {
63 for (size_t i = 0; i < NumValues; ++i) {
64 for (size_t j = 0; j < NumValues; ++j) {
65 ++TotalTests;
66 float Value1Float = Values[i];
67 float Value2Float = Values[j];
68 ResultSz = Funcs[f].FuncFloatSz(Value1Float, Value2Float);
69 ResultLlc = Funcs[f].FuncFloatLlc(Value1Float, Value2Float);
70 if (ResultSz == ResultLlc) {
71 ++Passes;
72 } else {
73 ++Failures;
74 std::cout << Funcs[f].Name << "Float(" << Value1Float << ", "
75 << Value2Float << "): sz=" << ResultSz
76 << " llc=" << ResultLlc << std::endl;
77 }
78 ++TotalTests;
79 double Value1Double = Values[i];
80 double Value2Double = Values[j];
81 ResultSz = Funcs[f].FuncDoubleSz(Value1Double, Value2Double);
82 ResultLlc = Funcs[f].FuncDoubleLlc(Value1Double, Value2Double);
83 if (ResultSz == ResultLlc) {
84 ++Passes;
85 } else {
86 ++Failures;
87 std::cout << Funcs[f].Name << "Double(" << Value1Double << ", "
88 << Value2Double << "): sz=" << ResultSz
89 << " llc=" << ResultLlc << std::endl;
90 }
91 }
92 }
93 }
94
95 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
96 << " Failures=" << Failures << "\n";
97 return Failures;
98 }
OLDNEW
« no previous file with comments | « crosstest/test_fcmp.pnacl.ll ('k') | crosstest/test_icmp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698