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

Side by Side Diff: test/unittests/compiler/simplified-operator-reducer-unittest.cc

Issue 2231963002: [turbofan] Avoid unnecessary minus zero checks for Float64->Tagged. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: REBASE Created 4 years, 4 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
OLDNEW
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/compiler/access-builder.h" 5 #include "src/compiler/access-builder.h"
6 #include "src/compiler/js-graph.h" 6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/node-properties.h" 7 #include "src/compiler/node-properties.h"
8 #include "src/compiler/simplified-operator.h" 8 #include "src/compiler/simplified-operator.h"
9 #include "src/compiler/simplified-operator-reducer.h" 9 #include "src/compiler/simplified-operator-reducer.h"
10 #include "src/conversions-inl.h" 10 #include "src/conversions-inl.h"
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 29755, 30554, 16476817, 605431957, 832401070, 873617242, 914205764, 90 29755, 30554, 16476817, 605431957, 832401070, 873617242, 914205764,
91 1062628108, 1087581664, 1488498068, 1534668023, 1661587028, 1696896187, 91 1062628108, 1087581664, 1488498068, 1534668023, 1661587028, 1696896187,
92 1866841746, 2032089723, 2147483647}; 92 1866841746, 2032089723, 2147483647};
93 93
94 94
95 const double kNaNs[] = {-std::numeric_limits<double>::quiet_NaN(), 95 const double kNaNs[] = {-std::numeric_limits<double>::quiet_NaN(),
96 std::numeric_limits<double>::quiet_NaN(), 96 std::numeric_limits<double>::quiet_NaN(),
97 bit_cast<double>(V8_UINT64_C(0x7FFFFFFFFFFFFFFF)), 97 bit_cast<double>(V8_UINT64_C(0x7FFFFFFFFFFFFFFF)),
98 bit_cast<double>(V8_UINT64_C(0xFFFFFFFFFFFFFFFF))}; 98 bit_cast<double>(V8_UINT64_C(0xFFFFFFFFFFFFFFFF))};
99 99
100 const CheckForMinusZeroMode kCheckForMinusZeroModes[] = {
101 CheckForMinusZeroMode::kDontCheckForMinusZero,
102 CheckForMinusZeroMode::kCheckForMinusZero};
103
100 } // namespace 104 } // namespace
101 105
102 106
103 // ----------------------------------------------------------------------------- 107 // -----------------------------------------------------------------------------
104 // BooleanNot 108 // BooleanNot
105 109
106 110
107 TEST_F(SimplifiedOperatorReducerTest, BooleanNotWithBooleanNot) { 111 TEST_F(SimplifiedOperatorReducerTest, BooleanNotWithBooleanNot) {
108 Node* param0 = Parameter(0); 112 Node* param0 = Parameter(0);
109 Reduction reduction = Reduce( 113 Reduction reduction = Reduce(
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 180
177 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToBitWithChangeBitToTagged) { 181 TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToBitWithChangeBitToTagged) {
178 Node* param0 = Parameter(0); 182 Node* param0 = Parameter(0);
179 Reduction reduction = Reduce(graph()->NewNode( 183 Reduction reduction = Reduce(graph()->NewNode(
180 simplified()->ChangeTaggedToBit(), 184 simplified()->ChangeTaggedToBit(),
181 graph()->NewNode(simplified()->ChangeBitToTagged(), param0))); 185 graph()->NewNode(simplified()->ChangeBitToTagged(), param0)));
182 ASSERT_TRUE(reduction.Changed()); 186 ASSERT_TRUE(reduction.Changed());
183 EXPECT_EQ(param0, reduction.replacement()); 187 EXPECT_EQ(param0, reduction.replacement());
184 } 188 }
185 189
186
187 // ----------------------------------------------------------------------------- 190 // -----------------------------------------------------------------------------
188 // ChangeFloat64ToTagged 191 // ChangeFloat64ToTagged
189 192
190
191 TEST_F(SimplifiedOperatorReducerTest, ChangeFloat64ToTaggedWithConstant) { 193 TEST_F(SimplifiedOperatorReducerTest, ChangeFloat64ToTaggedWithConstant) {
192 TRACED_FOREACH(double, n, kFloat64Values) { 194 TRACED_FOREACH(CheckForMinusZeroMode, mode, kCheckForMinusZeroModes) {
193 Reduction reduction = Reduce(graph()->NewNode( 195 TRACED_FOREACH(double, n, kFloat64Values) {
194 simplified()->ChangeFloat64ToTagged(), Float64Constant(n))); 196 Reduction reduction = Reduce(graph()->NewNode(
195 ASSERT_TRUE(reduction.Changed()); 197 simplified()->ChangeFloat64ToTagged(mode), Float64Constant(n)));
196 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(n))); 198 ASSERT_TRUE(reduction.Changed());
199 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(n)));
200 }
197 } 201 }
198 } 202 }
199 203
200
201 // ----------------------------------------------------------------------------- 204 // -----------------------------------------------------------------------------
202 // ChangeInt32ToTagged 205 // ChangeInt32ToTagged
203 206
204 207
205 TEST_F(SimplifiedOperatorReducerTest, ChangeInt32ToTaggedWithConstant) { 208 TEST_F(SimplifiedOperatorReducerTest, ChangeInt32ToTaggedWithConstant) {
206 TRACED_FOREACH(int32_t, n, kInt32Values) { 209 TRACED_FOREACH(int32_t, n, kInt32Values) {
207 Reduction reduction = Reduce(graph()->NewNode( 210 Reduction reduction = Reduce(graph()->NewNode(
208 simplified()->ChangeInt32ToTagged(), Int32Constant(n))); 211 simplified()->ChangeInt32ToTagged(), Int32Constant(n)));
209 ASSERT_TRUE(reduction.Changed()); 212 ASSERT_TRUE(reduction.Changed());
210 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(FastI2D(n)))); 213 EXPECT_THAT(reduction.replacement(), IsNumberConstant(BitEq(FastI2D(n))));
211 } 214 }
212 } 215 }
213 216
214 217
215 // ----------------------------------------------------------------------------- 218 // -----------------------------------------------------------------------------
216 // ChangeTaggedToFloat64 219 // ChangeTaggedToFloat64
217 220
218 221
219 TEST_F(SimplifiedOperatorReducerTest, 222 TEST_F(SimplifiedOperatorReducerTest,
220 ChangeTaggedToFloat64WithChangeFloat64ToTagged) { 223 ChangeTaggedToFloat64WithChangeFloat64ToTagged) {
221 Node* param0 = Parameter(0); 224 Node* param0 = Parameter(0);
222 Reduction reduction = Reduce(graph()->NewNode( 225 TRACED_FOREACH(CheckForMinusZeroMode, mode, kCheckForMinusZeroModes) {
223 simplified()->ChangeTaggedToFloat64(), 226 Reduction reduction = Reduce(graph()->NewNode(
224 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0))); 227 simplified()->ChangeTaggedToFloat64(),
225 ASSERT_TRUE(reduction.Changed()); 228 graph()->NewNode(simplified()->ChangeFloat64ToTagged(mode), param0)));
226 EXPECT_EQ(param0, reduction.replacement()); 229 ASSERT_TRUE(reduction.Changed());
230 EXPECT_EQ(param0, reduction.replacement());
231 }
227 } 232 }
228 233
229
230 TEST_F(SimplifiedOperatorReducerTest, 234 TEST_F(SimplifiedOperatorReducerTest,
231 ChangeTaggedToFloat64WithChangeInt32ToTagged) { 235 ChangeTaggedToFloat64WithChangeInt32ToTagged) {
232 Node* param0 = Parameter(0); 236 Node* param0 = Parameter(0);
233 Reduction reduction = Reduce(graph()->NewNode( 237 Reduction reduction = Reduce(graph()->NewNode(
234 simplified()->ChangeTaggedToFloat64(), 238 simplified()->ChangeTaggedToFloat64(),
235 graph()->NewNode(simplified()->ChangeInt32ToTagged(), param0))); 239 graph()->NewNode(simplified()->ChangeInt32ToTagged(), param0)));
236 ASSERT_TRUE(reduction.Changed()); 240 ASSERT_TRUE(reduction.Changed());
237 EXPECT_THAT(reduction.replacement(), IsChangeInt32ToFloat64(param0)); 241 EXPECT_THAT(reduction.replacement(), IsChangeInt32ToFloat64(param0));
238 } 242 }
239 243
(...skipping 25 matching lines...) Expand all
265 simplified()->ChangeTaggedToFloat64(), NumberConstant(nan))); 269 simplified()->ChangeTaggedToFloat64(), NumberConstant(nan)));
266 ASSERT_TRUE(reduction.Changed()); 270 ASSERT_TRUE(reduction.Changed());
267 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(BitEq(nan))); 271 EXPECT_THAT(reduction.replacement(), IsFloat64Constant(BitEq(nan)));
268 } 272 }
269 } 273 }
270 274
271 275
272 // ----------------------------------------------------------------------------- 276 // -----------------------------------------------------------------------------
273 // ChangeTaggedToInt32 277 // ChangeTaggedToInt32
274 278
275
276 TEST_F(SimplifiedOperatorReducerTest, 279 TEST_F(SimplifiedOperatorReducerTest,
277 ChangeTaggedToInt32WithChangeFloat64ToTagged) { 280 ChangeTaggedToInt32WithChangeFloat64ToTagged) {
278 Node* param0 = Parameter(0); 281 Node* param0 = Parameter(0);
279 Reduction reduction = Reduce(graph()->NewNode( 282 TRACED_FOREACH(CheckForMinusZeroMode, mode, kCheckForMinusZeroModes) {
280 simplified()->ChangeTaggedToInt32(), 283 Reduction reduction = Reduce(graph()->NewNode(
281 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0))); 284 simplified()->ChangeTaggedToInt32(),
282 ASSERT_TRUE(reduction.Changed()); 285 graph()->NewNode(simplified()->ChangeFloat64ToTagged(mode), param0)));
283 EXPECT_THAT(reduction.replacement(), IsChangeFloat64ToInt32(param0)); 286 ASSERT_TRUE(reduction.Changed());
287 EXPECT_THAT(reduction.replacement(), IsChangeFloat64ToInt32(param0));
288 }
284 } 289 }
285 290
286
287 TEST_F(SimplifiedOperatorReducerTest, 291 TEST_F(SimplifiedOperatorReducerTest,
288 ChangeTaggedToInt32WithChangeInt32ToTagged) { 292 ChangeTaggedToInt32WithChangeInt32ToTagged) {
289 Node* param0 = Parameter(0); 293 Node* param0 = Parameter(0);
290 Reduction reduction = Reduce(graph()->NewNode( 294 Reduction reduction = Reduce(graph()->NewNode(
291 simplified()->ChangeTaggedToInt32(), 295 simplified()->ChangeTaggedToInt32(),
292 graph()->NewNode(simplified()->ChangeInt32ToTagged(), param0))); 296 graph()->NewNode(simplified()->ChangeInt32ToTagged(), param0)));
293 ASSERT_TRUE(reduction.Changed()); 297 ASSERT_TRUE(reduction.Changed());
294 EXPECT_EQ(param0, reduction.replacement()); 298 EXPECT_EQ(param0, reduction.replacement());
295 } 299 }
296 300
297 301
298 // ----------------------------------------------------------------------------- 302 // -----------------------------------------------------------------------------
299 // ChangeTaggedToUint32 303 // ChangeTaggedToUint32
300 304
301
302 TEST_F(SimplifiedOperatorReducerTest, 305 TEST_F(SimplifiedOperatorReducerTest,
303 ChangeTaggedToUint32WithChangeFloat64ToTagged) { 306 ChangeTaggedToUint32WithChangeFloat64ToTagged) {
304 Node* param0 = Parameter(0); 307 Node* param0 = Parameter(0);
305 Reduction reduction = Reduce(graph()->NewNode( 308 TRACED_FOREACH(CheckForMinusZeroMode, mode, kCheckForMinusZeroModes) {
306 simplified()->ChangeTaggedToUint32(), 309 Reduction reduction = Reduce(graph()->NewNode(
307 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0))); 310 simplified()->ChangeTaggedToUint32(),
308 ASSERT_TRUE(reduction.Changed()); 311 graph()->NewNode(simplified()->ChangeFloat64ToTagged(mode), param0)));
309 EXPECT_THAT(reduction.replacement(), IsChangeFloat64ToUint32(param0)); 312 ASSERT_TRUE(reduction.Changed());
313 EXPECT_THAT(reduction.replacement(), IsChangeFloat64ToUint32(param0));
314 }
310 } 315 }
311 316
312
313 TEST_F(SimplifiedOperatorReducerTest, 317 TEST_F(SimplifiedOperatorReducerTest,
314 ChangeTaggedToUint32WithChangeUint32ToTagged) { 318 ChangeTaggedToUint32WithChangeUint32ToTagged) {
315 Node* param0 = Parameter(0); 319 Node* param0 = Parameter(0);
316 Reduction reduction = Reduce(graph()->NewNode( 320 Reduction reduction = Reduce(graph()->NewNode(
317 simplified()->ChangeTaggedToUint32(), 321 simplified()->ChangeTaggedToUint32(),
318 graph()->NewNode(simplified()->ChangeUint32ToTagged(), param0))); 322 graph()->NewNode(simplified()->ChangeUint32ToTagged(), param0)));
319 ASSERT_TRUE(reduction.Changed()); 323 ASSERT_TRUE(reduction.Changed());
320 EXPECT_EQ(param0, reduction.replacement()); 324 EXPECT_EQ(param0, reduction.replacement());
321 } 325 }
322 326
323 327
324 // ----------------------------------------------------------------------------- 328 // -----------------------------------------------------------------------------
325 // TruncateTaggedToWord32 329 // TruncateTaggedToWord32
326 330
327 TEST_F(SimplifiedOperatorReducerTest, 331 TEST_F(SimplifiedOperatorReducerTest,
328 TruncateTaggedToWord3WithChangeFloat64ToTagged) { 332 TruncateTaggedToWord3WithChangeFloat64ToTagged) {
329 Node* param0 = Parameter(0); 333 Node* param0 = Parameter(0);
330 Reduction reduction = Reduce(graph()->NewNode( 334 TRACED_FOREACH(CheckForMinusZeroMode, mode, kCheckForMinusZeroModes) {
331 simplified()->TruncateTaggedToWord32(), 335 Reduction reduction = Reduce(graph()->NewNode(
332 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0))); 336 simplified()->TruncateTaggedToWord32(),
333 ASSERT_TRUE(reduction.Changed()); 337 graph()->NewNode(simplified()->ChangeFloat64ToTagged(mode), param0)));
334 EXPECT_THAT(reduction.replacement(), IsTruncateFloat64ToWord32(param0)); 338 ASSERT_TRUE(reduction.Changed());
339 EXPECT_THAT(reduction.replacement(), IsTruncateFloat64ToWord32(param0));
340 }
335 } 341 }
336 342
337 TEST_F(SimplifiedOperatorReducerTest, TruncateTaggedToWord32WithConstant) { 343 TEST_F(SimplifiedOperatorReducerTest, TruncateTaggedToWord32WithConstant) {
338 TRACED_FOREACH(double, n, kFloat64Values) { 344 TRACED_FOREACH(double, n, kFloat64Values) {
339 Reduction reduction = Reduce(graph()->NewNode( 345 Reduction reduction = Reduce(graph()->NewNode(
340 simplified()->TruncateTaggedToWord32(), NumberConstant(n))); 346 simplified()->TruncateTaggedToWord32(), NumberConstant(n)));
341 ASSERT_TRUE(reduction.Changed()); 347 ASSERT_TRUE(reduction.Changed());
342 EXPECT_THAT(reduction.replacement(), IsInt32Constant(DoubleToInt32(n))); 348 EXPECT_THAT(reduction.replacement(), IsInt32Constant(DoubleToInt32(n)));
343 } 349 }
344 } 350 }
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 Reduction reduction = Reduce( 455 Reduction reduction = Reduce(
450 graph()->NewNode(simplified()->ObjectIsSmi(), NumberConstant(n))); 456 graph()->NewNode(simplified()->ObjectIsSmi(), NumberConstant(n)));
451 ASSERT_TRUE(reduction.Changed()); 457 ASSERT_TRUE(reduction.Changed());
452 EXPECT_THAT(reduction.replacement(), IsBooleanConstant(IsSmiDouble(n))); 458 EXPECT_THAT(reduction.replacement(), IsBooleanConstant(IsSmiDouble(n)));
453 } 459 }
454 } 460 }
455 461
456 } // namespace compiler 462 } // namespace compiler
457 } // namespace internal 463 } // namespace internal
458 } // namespace v8 464 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-operator.cc ('k') | test/unittests/compiler/simplified-operator-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698