OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "test/cctest/cctest.h" | 7 #include "test/cctest/cctest.h" |
8 #include "test/cctest/compiler/codegen-tester.h" | 8 #include "test/cctest/compiler/codegen-tester.h" |
9 #include "test/cctest/compiler/value-helper.h" | 9 #include "test/cctest/compiler/value-helper.h" |
10 | 10 |
11 #if V8_TURBOFAN_TARGET | 11 #if V8_TURBOFAN_TARGET |
12 | 12 |
13 using namespace v8::internal; | 13 using namespace v8::internal; |
14 using namespace v8::internal::compiler; | 14 using namespace v8::internal::compiler; |
15 | 15 |
16 typedef RawMachineAssembler::Label MLabel; | 16 typedef RawMachineAssembler::Label MLabel; |
17 | 17 |
18 static IrOpcode::Value int32cmp_opcodes[] = { | 18 static IrOpcode::Value int32cmp_opcodes[] = { |
19 IrOpcode::kWord32Equal, IrOpcode::kInt32LessThan, | 19 IrOpcode::kWord32Equal, IrOpcode::kInt32LessThan, |
20 IrOpcode::kInt32LessThanOrEqual, IrOpcode::kUint32LessThan, | 20 IrOpcode::kInt32LessThanOrEqual, IrOpcode::kUint32LessThan, |
21 IrOpcode::kUint32LessThanOrEqual}; | 21 IrOpcode::kUint32LessThanOrEqual}; |
22 | 22 |
23 | 23 |
24 TEST(BranchCombineWord32EqualZero_1) { | 24 TEST(BranchCombineWord32EqualZero_1) { |
25 // Test combining a branch with x == 0 | 25 // Test combining a branch with x == 0 |
26 RawMachineAssemblerTester<int32_t> m(kMachineWord32); | 26 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
27 int32_t eq_constant = -1033; | 27 int32_t eq_constant = -1033; |
28 int32_t ne_constant = 825118; | 28 int32_t ne_constant = 825118; |
29 Node* p0 = m.Parameter(0); | 29 Node* p0 = m.Parameter(0); |
30 | 30 |
31 MLabel blocka, blockb; | 31 MLabel blocka, blockb; |
32 m.Branch(m.Word32Equal(p0, m.Int32Constant(0)), &blocka, &blockb); | 32 m.Branch(m.Word32Equal(p0, m.Int32Constant(0)), &blocka, &blockb); |
33 m.Bind(&blocka); | 33 m.Bind(&blocka); |
34 m.Return(m.Int32Constant(eq_constant)); | 34 m.Return(m.Int32Constant(eq_constant)); |
35 m.Bind(&blockb); | 35 m.Bind(&blockb); |
36 m.Return(m.Int32Constant(ne_constant)); | 36 m.Return(m.Int32Constant(ne_constant)); |
37 | 37 |
38 FOR_INT32_INPUTS(i) { | 38 FOR_INT32_INPUTS(i) { |
39 int32_t a = *i; | 39 int32_t a = *i; |
40 int32_t expect = a == 0 ? eq_constant : ne_constant; | 40 int32_t expect = a == 0 ? eq_constant : ne_constant; |
41 CHECK_EQ(expect, m.Call(a)); | 41 CHECK_EQ(expect, m.Call(a)); |
42 } | 42 } |
43 } | 43 } |
44 | 44 |
45 | 45 |
46 TEST(BranchCombineWord32EqualZero_chain) { | 46 TEST(BranchCombineWord32EqualZero_chain) { |
47 // Test combining a branch with a chain of x == 0 == 0 == 0 ... | 47 // Test combining a branch with a chain of x == 0 == 0 == 0 ... |
48 int32_t eq_constant = -1133; | 48 int32_t eq_constant = -1133; |
49 int32_t ne_constant = 815118; | 49 int32_t ne_constant = 815118; |
50 | 50 |
51 for (int k = 0; k < 6; k++) { | 51 for (int k = 0; k < 6; k++) { |
52 RawMachineAssemblerTester<int32_t> m(kMachineWord32); | 52 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
53 Node* p0 = m.Parameter(0); | 53 Node* p0 = m.Parameter(0); |
54 MLabel blocka, blockb; | 54 MLabel blocka, blockb; |
55 Node* cond = p0; | 55 Node* cond = p0; |
56 for (int j = 0; j < k; j++) { | 56 for (int j = 0; j < k; j++) { |
57 cond = m.Word32Equal(cond, m.Int32Constant(0)); | 57 cond = m.Word32Equal(cond, m.Int32Constant(0)); |
58 } | 58 } |
59 m.Branch(cond, &blocka, &blockb); | 59 m.Branch(cond, &blocka, &blockb); |
60 m.Bind(&blocka); | 60 m.Bind(&blocka); |
61 m.Return(m.Int32Constant(eq_constant)); | 61 m.Return(m.Int32Constant(eq_constant)); |
62 m.Bind(&blockb); | 62 m.Bind(&blockb); |
63 m.Return(m.Int32Constant(ne_constant)); | 63 m.Return(m.Int32Constant(ne_constant)); |
64 | 64 |
65 FOR_INT32_INPUTS(i) { | 65 FOR_INT32_INPUTS(i) { |
66 int32_t a = *i; | 66 int32_t a = *i; |
67 int32_t expect = (k & 1) == 1 ? (a == 0 ? eq_constant : ne_constant) | 67 int32_t expect = (k & 1) == 1 ? (a == 0 ? eq_constant : ne_constant) |
68 : (a == 0 ? ne_constant : eq_constant); | 68 : (a == 0 ? ne_constant : eq_constant); |
69 CHECK_EQ(expect, m.Call(a)); | 69 CHECK_EQ(expect, m.Call(a)); |
70 } | 70 } |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 | 74 |
75 TEST(BranchCombineInt32LessThanZero_1) { | 75 TEST(BranchCombineInt32LessThanZero_1) { |
76 // Test combining a branch with x < 0 | 76 // Test combining a branch with x < 0 |
77 RawMachineAssemblerTester<int32_t> m(kMachineWord32); | 77 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
78 int32_t eq_constant = -1433; | 78 int32_t eq_constant = -1433; |
79 int32_t ne_constant = 845118; | 79 int32_t ne_constant = 845118; |
80 Node* p0 = m.Parameter(0); | 80 Node* p0 = m.Parameter(0); |
81 | 81 |
82 MLabel blocka, blockb; | 82 MLabel blocka, blockb; |
83 m.Branch(m.Int32LessThan(p0, m.Int32Constant(0)), &blocka, &blockb); | 83 m.Branch(m.Int32LessThan(p0, m.Int32Constant(0)), &blocka, &blockb); |
84 m.Bind(&blocka); | 84 m.Bind(&blocka); |
85 m.Return(m.Int32Constant(eq_constant)); | 85 m.Return(m.Int32Constant(eq_constant)); |
86 m.Bind(&blockb); | 86 m.Bind(&blockb); |
87 m.Return(m.Int32Constant(ne_constant)); | 87 m.Return(m.Int32Constant(ne_constant)); |
88 | 88 |
89 FOR_INT32_INPUTS(i) { | 89 FOR_INT32_INPUTS(i) { |
90 int32_t a = *i; | 90 int32_t a = *i; |
91 int32_t expect = a < 0 ? eq_constant : ne_constant; | 91 int32_t expect = a < 0 ? eq_constant : ne_constant; |
92 CHECK_EQ(expect, m.Call(a)); | 92 CHECK_EQ(expect, m.Call(a)); |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 | 96 |
97 TEST(BranchCombineUint32LessThan100_1) { | 97 TEST(BranchCombineUint32LessThan100_1) { |
98 // Test combining a branch with x < 100 | 98 // Test combining a branch with x < 100 |
99 RawMachineAssemblerTester<int32_t> m(kMachineWord32); | 99 RawMachineAssemblerTester<int32_t> m(kMachUint32); |
100 int32_t eq_constant = 1471; | 100 int32_t eq_constant = 1471; |
101 int32_t ne_constant = 88845718; | 101 int32_t ne_constant = 88845718; |
102 Node* p0 = m.Parameter(0); | 102 Node* p0 = m.Parameter(0); |
103 | 103 |
104 MLabel blocka, blockb; | 104 MLabel blocka, blockb; |
105 m.Branch(m.Uint32LessThan(p0, m.Int32Constant(100)), &blocka, &blockb); | 105 m.Branch(m.Uint32LessThan(p0, m.Int32Constant(100)), &blocka, &blockb); |
106 m.Bind(&blocka); | 106 m.Bind(&blocka); |
107 m.Return(m.Int32Constant(eq_constant)); | 107 m.Return(m.Int32Constant(eq_constant)); |
108 m.Bind(&blockb); | 108 m.Bind(&blockb); |
109 m.Return(m.Int32Constant(ne_constant)); | 109 m.Return(m.Int32Constant(ne_constant)); |
110 | 110 |
111 FOR_UINT32_INPUTS(i) { | 111 FOR_UINT32_INPUTS(i) { |
112 uint32_t a = *i; | 112 uint32_t a = *i; |
113 int32_t expect = a < 100 ? eq_constant : ne_constant; | 113 int32_t expect = a < 100 ? eq_constant : ne_constant; |
114 CHECK_EQ(expect, m.Call(a)); | 114 CHECK_EQ(expect, m.Call(a)); |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
118 | 118 |
119 TEST(BranchCombineUint32LessThanOrEqual100_1) { | 119 TEST(BranchCombineUint32LessThanOrEqual100_1) { |
120 // Test combining a branch with x <= 100 | 120 // Test combining a branch with x <= 100 |
121 RawMachineAssemblerTester<int32_t> m(kMachineWord32); | 121 RawMachineAssemblerTester<int32_t> m(kMachUint32); |
122 int32_t eq_constant = 1479; | 122 int32_t eq_constant = 1479; |
123 int32_t ne_constant = 77845719; | 123 int32_t ne_constant = 77845719; |
124 Node* p0 = m.Parameter(0); | 124 Node* p0 = m.Parameter(0); |
125 | 125 |
126 MLabel blocka, blockb; | 126 MLabel blocka, blockb; |
127 m.Branch(m.Uint32LessThanOrEqual(p0, m.Int32Constant(100)), &blocka, &blockb); | 127 m.Branch(m.Uint32LessThanOrEqual(p0, m.Int32Constant(100)), &blocka, &blockb); |
128 m.Bind(&blocka); | 128 m.Bind(&blocka); |
129 m.Return(m.Int32Constant(eq_constant)); | 129 m.Return(m.Int32Constant(eq_constant)); |
130 m.Bind(&blockb); | 130 m.Bind(&blockb); |
131 m.Return(m.Int32Constant(ne_constant)); | 131 m.Return(m.Int32Constant(ne_constant)); |
132 | 132 |
133 FOR_UINT32_INPUTS(i) { | 133 FOR_UINT32_INPUTS(i) { |
134 uint32_t a = *i; | 134 uint32_t a = *i; |
135 int32_t expect = a <= 100 ? eq_constant : ne_constant; | 135 int32_t expect = a <= 100 ? eq_constant : ne_constant; |
136 CHECK_EQ(expect, m.Call(a)); | 136 CHECK_EQ(expect, m.Call(a)); |
137 } | 137 } |
138 } | 138 } |
139 | 139 |
140 | 140 |
141 TEST(BranchCombineZeroLessThanInt32_1) { | 141 TEST(BranchCombineZeroLessThanInt32_1) { |
142 // Test combining a branch with 0 < x | 142 // Test combining a branch with 0 < x |
143 RawMachineAssemblerTester<int32_t> m(kMachineWord32); | 143 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
144 int32_t eq_constant = -2033; | 144 int32_t eq_constant = -2033; |
145 int32_t ne_constant = 225118; | 145 int32_t ne_constant = 225118; |
146 Node* p0 = m.Parameter(0); | 146 Node* p0 = m.Parameter(0); |
147 | 147 |
148 MLabel blocka, blockb; | 148 MLabel blocka, blockb; |
149 m.Branch(m.Int32LessThan(m.Int32Constant(0), p0), &blocka, &blockb); | 149 m.Branch(m.Int32LessThan(m.Int32Constant(0), p0), &blocka, &blockb); |
150 m.Bind(&blocka); | 150 m.Bind(&blocka); |
151 m.Return(m.Int32Constant(eq_constant)); | 151 m.Return(m.Int32Constant(eq_constant)); |
152 m.Bind(&blockb); | 152 m.Bind(&blockb); |
153 m.Return(m.Int32Constant(ne_constant)); | 153 m.Return(m.Int32Constant(ne_constant)); |
154 | 154 |
155 FOR_INT32_INPUTS(i) { | 155 FOR_INT32_INPUTS(i) { |
156 int32_t a = *i; | 156 int32_t a = *i; |
157 int32_t expect = 0 < a ? eq_constant : ne_constant; | 157 int32_t expect = 0 < a ? eq_constant : ne_constant; |
158 CHECK_EQ(expect, m.Call(a)); | 158 CHECK_EQ(expect, m.Call(a)); |
159 } | 159 } |
160 } | 160 } |
161 | 161 |
162 | 162 |
163 TEST(BranchCombineInt32GreaterThanZero_1) { | 163 TEST(BranchCombineInt32GreaterThanZero_1) { |
164 // Test combining a branch with x > 0 | 164 // Test combining a branch with x > 0 |
165 RawMachineAssemblerTester<int32_t> m(kMachineWord32); | 165 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
166 int32_t eq_constant = -1073; | 166 int32_t eq_constant = -1073; |
167 int32_t ne_constant = 825178; | 167 int32_t ne_constant = 825178; |
168 Node* p0 = m.Parameter(0); | 168 Node* p0 = m.Parameter(0); |
169 | 169 |
170 MLabel blocka, blockb; | 170 MLabel blocka, blockb; |
171 m.Branch(m.Int32GreaterThan(p0, m.Int32Constant(0)), &blocka, &blockb); | 171 m.Branch(m.Int32GreaterThan(p0, m.Int32Constant(0)), &blocka, &blockb); |
172 m.Bind(&blocka); | 172 m.Bind(&blocka); |
173 m.Return(m.Int32Constant(eq_constant)); | 173 m.Return(m.Int32Constant(eq_constant)); |
174 m.Bind(&blockb); | 174 m.Bind(&blockb); |
175 m.Return(m.Int32Constant(ne_constant)); | 175 m.Return(m.Int32Constant(ne_constant)); |
176 | 176 |
177 FOR_INT32_INPUTS(i) { | 177 FOR_INT32_INPUTS(i) { |
178 int32_t a = *i; | 178 int32_t a = *i; |
179 int32_t expect = a > 0 ? eq_constant : ne_constant; | 179 int32_t expect = a > 0 ? eq_constant : ne_constant; |
180 CHECK_EQ(expect, m.Call(a)); | 180 CHECK_EQ(expect, m.Call(a)); |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 | 184 |
185 TEST(BranchCombineWord32EqualP) { | 185 TEST(BranchCombineWord32EqualP) { |
186 // Test combining a branch with an Word32Equal. | 186 // Test combining a branch with an Word32Equal. |
187 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); | 187 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); |
188 int32_t eq_constant = -1035; | 188 int32_t eq_constant = -1035; |
189 int32_t ne_constant = 825018; | 189 int32_t ne_constant = 825018; |
190 Node* p0 = m.Parameter(0); | 190 Node* p0 = m.Parameter(0); |
191 Node* p1 = m.Parameter(1); | 191 Node* p1 = m.Parameter(1); |
192 | 192 |
193 MLabel blocka, blockb; | 193 MLabel blocka, blockb; |
194 m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); | 194 m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); |
195 m.Bind(&blocka); | 195 m.Bind(&blocka); |
196 m.Return(m.Int32Constant(eq_constant)); | 196 m.Return(m.Int32Constant(eq_constant)); |
197 m.Bind(&blockb); | 197 m.Bind(&blockb); |
198 m.Return(m.Int32Constant(ne_constant)); | 198 m.Return(m.Int32Constant(ne_constant)); |
199 | 199 |
200 FOR_INT32_INPUTS(i) { | 200 FOR_INT32_INPUTS(i) { |
201 FOR_INT32_INPUTS(j) { | 201 FOR_INT32_INPUTS(j) { |
202 int32_t a = *i; | 202 int32_t a = *i; |
203 int32_t b = *j; | 203 int32_t b = *j; |
204 int32_t expect = a == b ? eq_constant : ne_constant; | 204 int32_t expect = a == b ? eq_constant : ne_constant; |
205 CHECK_EQ(expect, m.Call(a, b)); | 205 CHECK_EQ(expect, m.Call(a, b)); |
206 } | 206 } |
207 } | 207 } |
208 } | 208 } |
209 | 209 |
210 | 210 |
211 TEST(BranchCombineWord32EqualI) { | 211 TEST(BranchCombineWord32EqualI) { |
212 int32_t eq_constant = -1135; | 212 int32_t eq_constant = -1135; |
213 int32_t ne_constant = 925718; | 213 int32_t ne_constant = 925718; |
214 | 214 |
215 for (int left = 0; left < 2; left++) { | 215 for (int left = 0; left < 2; left++) { |
216 FOR_INT32_INPUTS(i) { | 216 FOR_INT32_INPUTS(i) { |
217 RawMachineAssemblerTester<int32_t> m(kMachineWord32); | 217 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
218 int32_t a = *i; | 218 int32_t a = *i; |
219 | 219 |
220 Node* p0 = m.Int32Constant(a); | 220 Node* p0 = m.Int32Constant(a); |
221 Node* p1 = m.Parameter(0); | 221 Node* p1 = m.Parameter(0); |
222 | 222 |
223 MLabel blocka, blockb; | 223 MLabel blocka, blockb; |
224 if (left == 1) m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); | 224 if (left == 1) m.Branch(m.Word32Equal(p0, p1), &blocka, &blockb); |
225 if (left == 0) m.Branch(m.Word32Equal(p1, p0), &blocka, &blockb); | 225 if (left == 0) m.Branch(m.Word32Equal(p1, p0), &blocka, &blockb); |
226 m.Bind(&blocka); | 226 m.Bind(&blocka); |
227 m.Return(m.Int32Constant(eq_constant)); | 227 m.Return(m.Int32Constant(eq_constant)); |
228 m.Bind(&blockb); | 228 m.Bind(&blockb); |
229 m.Return(m.Int32Constant(ne_constant)); | 229 m.Return(m.Int32Constant(ne_constant)); |
230 | 230 |
231 FOR_INT32_INPUTS(j) { | 231 FOR_INT32_INPUTS(j) { |
232 int32_t b = *j; | 232 int32_t b = *j; |
233 int32_t expect = a == b ? eq_constant : ne_constant; | 233 int32_t expect = a == b ? eq_constant : ne_constant; |
234 CHECK_EQ(expect, m.Call(b)); | 234 CHECK_EQ(expect, m.Call(b)); |
235 } | 235 } |
236 } | 236 } |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 | 240 |
241 TEST(BranchCombineInt32CmpP) { | 241 TEST(BranchCombineInt32CmpP) { |
242 int32_t eq_constant = -1235; | 242 int32_t eq_constant = -1235; |
243 int32_t ne_constant = 725018; | 243 int32_t ne_constant = 725018; |
244 | 244 |
245 for (int op = 0; op < 2; op++) { | 245 for (int op = 0; op < 2; op++) { |
246 RawMachineAssemblerTester<int32_t> m(kMachineWord32, kMachineWord32); | 246 RawMachineAssemblerTester<int32_t> m(kMachInt32, kMachInt32); |
247 Node* p0 = m.Parameter(0); | 247 Node* p0 = m.Parameter(0); |
248 Node* p1 = m.Parameter(1); | 248 Node* p1 = m.Parameter(1); |
249 | 249 |
250 MLabel blocka, blockb; | 250 MLabel blocka, blockb; |
251 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); | 251 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); |
252 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); | 252 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); |
253 m.Bind(&blocka); | 253 m.Bind(&blocka); |
254 m.Return(m.Int32Constant(eq_constant)); | 254 m.Return(m.Int32Constant(eq_constant)); |
255 m.Bind(&blockb); | 255 m.Bind(&blockb); |
256 m.Return(m.Int32Constant(ne_constant)); | 256 m.Return(m.Int32Constant(ne_constant)); |
(...skipping 11 matching lines...) Expand all Loading... |
268 } | 268 } |
269 } | 269 } |
270 | 270 |
271 | 271 |
272 TEST(BranchCombineInt32CmpI) { | 272 TEST(BranchCombineInt32CmpI) { |
273 int32_t eq_constant = -1175; | 273 int32_t eq_constant = -1175; |
274 int32_t ne_constant = 927711; | 274 int32_t ne_constant = 927711; |
275 | 275 |
276 for (int op = 0; op < 2; op++) { | 276 for (int op = 0; op < 2; op++) { |
277 FOR_INT32_INPUTS(i) { | 277 FOR_INT32_INPUTS(i) { |
278 RawMachineAssemblerTester<int32_t> m(kMachineWord32); | 278 RawMachineAssemblerTester<int32_t> m(kMachInt32); |
279 int32_t a = *i; | 279 int32_t a = *i; |
280 Node* p0 = m.Int32Constant(a); | 280 Node* p0 = m.Int32Constant(a); |
281 Node* p1 = m.Parameter(0); | 281 Node* p1 = m.Parameter(0); |
282 | 282 |
283 MLabel blocka, blockb; | 283 MLabel blocka, blockb; |
284 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); | 284 if (op == 0) m.Branch(m.Int32LessThan(p0, p1), &blocka, &blockb); |
285 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); | 285 if (op == 1) m.Branch(m.Int32LessThanOrEqual(p0, p1), &blocka, &blockb); |
286 m.Bind(&blocka); | 286 m.Bind(&blocka); |
287 m.Return(m.Int32Constant(eq_constant)); | 287 m.Return(m.Int32Constant(eq_constant)); |
288 m.Bind(&blockb); | 288 m.Bind(&blockb); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 double input_b = 0.0; | 425 double input_b = 0.0; |
426 | 426 |
427 CompareWrapper cmps[] = {CompareWrapper(IrOpcode::kFloat64Equal), | 427 CompareWrapper cmps[] = {CompareWrapper(IrOpcode::kFloat64Equal), |
428 CompareWrapper(IrOpcode::kFloat64LessThan), | 428 CompareWrapper(IrOpcode::kFloat64LessThan), |
429 CompareWrapper(IrOpcode::kFloat64LessThanOrEqual)}; | 429 CompareWrapper(IrOpcode::kFloat64LessThanOrEqual)}; |
430 | 430 |
431 for (size_t c = 0; c < ARRAY_SIZE(cmps); c++) { | 431 for (size_t c = 0; c < ARRAY_SIZE(cmps); c++) { |
432 CompareWrapper cmp = cmps[c]; | 432 CompareWrapper cmp = cmps[c]; |
433 for (int invert = 0; invert < 2; invert++) { | 433 for (int invert = 0; invert < 2; invert++) { |
434 RawMachineAssemblerTester<int32_t> m; | 434 RawMachineAssemblerTester<int32_t> m; |
435 Node* a = m.LoadFromPointer(&input_a, kMachineFloat64); | 435 Node* a = m.LoadFromPointer(&input_a, kMachFloat64); |
436 Node* b = m.LoadFromPointer(&input_b, kMachineFloat64); | 436 Node* b = m.LoadFromPointer(&input_b, kMachFloat64); |
437 | 437 |
438 MLabel blocka, blockb; | 438 MLabel blocka, blockb; |
439 Node* cond = cmp.MakeNode(&m, a, b); | 439 Node* cond = cmp.MakeNode(&m, a, b); |
440 if (invert) cond = m.Word32Equal(cond, m.Int32Constant(0)); | 440 if (invert) cond = m.Word32Equal(cond, m.Int32Constant(0)); |
441 m.Branch(cond, &blocka, &blockb); | 441 m.Branch(cond, &blocka, &blockb); |
442 m.Bind(&blocka); | 442 m.Bind(&blocka); |
443 m.Return(m.Int32Constant(eq_constant)); | 443 m.Return(m.Int32Constant(eq_constant)); |
444 m.Bind(&blockb); | 444 m.Bind(&blockb); |
445 m.Return(m.Int32Constant(ne_constant)); | 445 m.Return(m.Int32Constant(ne_constant)); |
446 | 446 |
447 for (size_t i = 0; i < ARRAY_SIZE(inputs); i++) { | 447 for (size_t i = 0; i < ARRAY_SIZE(inputs); i++) { |
448 for (size_t j = 0; j < ARRAY_SIZE(inputs); j += 2) { | 448 for (size_t j = 0; j < ARRAY_SIZE(inputs); j += 2) { |
449 input_a = inputs[i]; | 449 input_a = inputs[i]; |
450 input_b = inputs[i]; | 450 input_b = inputs[i]; |
451 int32_t expected = | 451 int32_t expected = |
452 invert ? (cmp.Float64Compare(input_a, input_b) ? ne_constant | 452 invert ? (cmp.Float64Compare(input_a, input_b) ? ne_constant |
453 : eq_constant) | 453 : eq_constant) |
454 : (cmp.Float64Compare(input_a, input_b) ? eq_constant | 454 : (cmp.Float64Compare(input_a, input_b) ? eq_constant |
455 : ne_constant); | 455 : ne_constant); |
456 CHECK_EQ(expected, m.Call()); | 456 CHECK_EQ(expected, m.Call()); |
457 } | 457 } |
458 } | 458 } |
459 } | 459 } |
460 } | 460 } |
461 } | 461 } |
462 #endif // V8_TURBOFAN_TARGET | 462 #endif // V8_TURBOFAN_TARGET |
OLD | NEW |