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

Side by Side Diff: crosstest/test_select_main.cpp

Issue 639543002: Add cross test for vector itofp and fptoi casts. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: share more Created 6 years, 2 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_main.cpp ('k') | pydir/crosstest.py » ('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_select_main.cpp - Driver for tests ----------===// 1 //===- subzero/crosstest/test_select_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 the select bitcode instruction 10 // Driver for crosstesting the select bitcode instruction
11 // 11 //
12 //===----------------------------------------------------------------------===// 12 //===----------------------------------------------------------------------===//
13 13
14 /* crosstest.py --test=test_select.ll --driver=test_select_main.cpp \ 14 /* crosstest.py --test=test_select.ll --driver=test_select_main.cpp \
15 --prefix=Subzero_ --output=test_select */ 15 --prefix=Subzero_ --output=test_select */
16 16
17 #include <cfloat> 17 #include <cfloat>
18 #include <cstring> 18 #include <cstring>
19 #include <iostream> 19 #include <iostream>
20 20
21 #include "test_arith.def"
21 #include "test_select.h" 22 #include "test_select.h"
22 23
23 namespace Subzero_ { 24 namespace Subzero_ {
24 #include "test_select.h" 25 #include "test_select.h"
25 } 26 }
26 27
27 static const size_t MaxTestsPerFunc = 100000; 28 static const size_t MaxTestsPerFunc = 100000;
28 29
29 template <typename T, typename TI1> 30 template <typename T, typename TI1>
30 void testSelect(size_t &TotalTests, size_t &Passes, size_t &Failures) { 31 void testSelect(size_t &TotalTests, size_t &Passes, size_t &Failures) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 } 66 }
66 } 67 }
67 } 68 }
68 69
69 template<> void 70 template<> void
70 testSelect<v4f32, v4i1>(size_t &TotalTests, size_t &Passes, size_t &Failures) { 71 testSelect<v4f32, v4i1>(size_t &TotalTests, size_t &Passes, size_t &Failures) {
71 static const float NegInf = -1.0 / 0.0; 72 static const float NegInf = -1.0 / 0.0;
72 static const float PosInf = 1.0 / 0.0; 73 static const float PosInf = 1.0 / 0.0;
73 static const float Nan = 0.0 / 0.0; 74 static const float Nan = 0.0 / 0.0;
74 static const float NegNan = -0.0 / 0.0; 75 static const float NegNan = -0.0 / 0.0;
75 volatile float Values[] = { 76 volatile float Values[] = FP_VALUE_ARRAY(NegInf, PosInf, NegNan, Nan);
76 0, 1, 0x7e,
77 0x7f, 0x80, 0x81,
78 0xfe, 0xff, 0x7ffe,
79 0x7fff, 0x8000, 0x8001,
80 0xfffe, 0xffff, 0x7ffffffe,
81 0x7fffffff, 0x80000000, 0x80000001,
82 0xfffffffe, 0xffffffff, 0x100000000ll,
83 0x100000001ll, 0x7ffffffffffffffell, 0x7fffffffffffffffll,
84 0x8000000000000000ll, 0x8000000000000001ll, 0xfffffffffffffffell,
85 0xffffffffffffffffll, NegInf, PosInf,
86 Nan, NegNan, -0.0,
87 FLT_MIN, FLT_MAX, DBL_MIN,
88 DBL_MAX
89 };
90 static const size_t NumValues = sizeof(Values) / sizeof(*Values); 77 static const size_t NumValues = sizeof(Values) / sizeof(*Values);
91 static const size_t NumElements = 4; 78 static const size_t NumElements = 4;
92 PRNG Index; 79 PRNG Index;
93 for (size_t i = 0; i < MaxTestsPerFunc; ++i) { 80 for (size_t i = 0; i < MaxTestsPerFunc; ++i) {
94 v4si32 Cond; 81 v4si32 Cond;
95 v4f32 Value1, Value2; 82 v4f32 Value1, Value2;
96 for (size_t j = 0; j < NumElements; ++j) { 83 for (size_t j = 0; j < NumElements; ++j) {
97 Cond[j] = Index() % 2; 84 Cond[j] = Index() % 2;
98 Value1[j] = Values[Index() % NumValues]; 85 Value1[j] = Values[Index() % NumValues];
99 Value2[j] = Values[Index() % NumValues]; 86 Value2[j] = Values[Index() % NumValues];
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 testSelect<v16ui8, v16i1>(TotalTests, Passes, Failures); 146 testSelect<v16ui8, v16i1>(TotalTests, Passes, Failures);
160 testSelectI1<v4i1>(TotalTests, Passes, Failures); 147 testSelectI1<v4i1>(TotalTests, Passes, Failures);
161 testSelectI1<v8i1>(TotalTests, Passes, Failures); 148 testSelectI1<v8i1>(TotalTests, Passes, Failures);
162 testSelectI1<v16i1>(TotalTests, Passes, Failures); 149 testSelectI1<v16i1>(TotalTests, Passes, Failures);
163 150
164 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes 151 std::cout << "TotalTests=" << TotalTests << " Passes=" << Passes
165 << " Failures=" << Failures << "\n"; 152 << " Failures=" << Failures << "\n";
166 153
167 return Failures; 154 return Failures;
168 } 155 }
OLDNEW
« no previous file with comments | « crosstest/test_fcmp_main.cpp ('k') | pydir/crosstest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698