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/compiler/change-lowering.h" | 5 #include "src/compiler/change-lowering.h" |
6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
7 #include "src/compiler/node-properties-inl.h" | 7 #include "src/compiler/node-properties-inl.h" |
8 #include "src/compiler/simplified-operator.h" | 8 #include "src/compiler/simplified-operator.h" |
9 #include "src/compiler/typer.h" | 9 #include "src/compiler/typer.h" |
10 #include "test/compiler-unittests/graph-unittest.h" | 10 #include "test/compiler-unittests/graph-unittest.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
262 | 262 |
263 Node* val = Parameter(0); | 263 Node* val = Parameter(0); |
264 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val); | 264 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val); |
265 Reduction reduction = Reduce(node); | 265 Reduction reduction = Reduce(node); |
266 ASSERT_TRUE(reduction.Changed()); | 266 ASSERT_TRUE(reduction.Changed()); |
267 | 267 |
268 Node* phi = reduction.replacement(); | 268 Node* phi = reduction.replacement(); |
269 Capture<Node*> branch, if_true; | 269 Capture<Node*> branch, if_true; |
270 EXPECT_THAT( | 270 EXPECT_THAT( |
271 phi, | 271 phi, |
272 IsPhi(IsTruncateFloat64ToInt32(IsLoad( | 272 IsPhi(IsChangeFloat64ToInt32(IsLoad( |
273 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()), | 273 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()), |
274 IsControlEffect(CaptureEq(&if_true)))), | 274 IsControlEffect(CaptureEq(&if_true)))), |
275 IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())), | 275 IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())), |
276 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 276 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
277 IsIfFalse(AllOf( | 277 IsIfFalse(AllOf( |
278 CaptureEq(&branch), | 278 CaptureEq(&branch), |
279 IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), | 279 IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), |
280 graph()->start())))))); | 280 graph()->start())))))); |
281 } | 281 } |
282 | 282 |
283 | 283 |
284 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToUint32) { | 284 TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToUint32) { |
285 STATIC_ASSERT(kSmiTag == 0); | 285 STATIC_ASSERT(kSmiTag == 0); |
286 STATIC_ASSERT(kSmiTagSize == 1); | 286 STATIC_ASSERT(kSmiTagSize == 1); |
287 | 287 |
288 Node* val = Parameter(0); | 288 Node* val = Parameter(0); |
289 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val); | 289 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val); |
290 Reduction reduction = Reduce(node); | 290 Reduction reduction = Reduce(node); |
291 ASSERT_TRUE(reduction.Changed()); | 291 ASSERT_TRUE(reduction.Changed()); |
292 | 292 |
293 Node* phi = reduction.replacement(); | 293 Node* phi = reduction.replacement(); |
294 Capture<Node*> branch, if_true; | 294 Capture<Node*> branch, if_true; |
295 EXPECT_THAT( | 295 EXPECT_THAT( |
296 phi, | 296 phi, |
297 IsPhi(IsTruncateFloat64ToInt32(IsLoad( | 297 IsPhi(IsChangeFloat64ToUint32(IsLoad( |
298 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()), | 298 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()), |
299 IsControlEffect(CaptureEq(&if_true)))), | 299 IsControlEffect(CaptureEq(&if_true)))), |
300 IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())), | 300 IsWord32Sar(val, IsInt32Constant(SmiShiftAmount())), |
301 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 301 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
302 IsIfFalse(AllOf( | 302 IsIfFalse(AllOf( |
303 CaptureEq(&branch), | 303 CaptureEq(&branch), |
304 IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), | 304 IsBranch(IsWord32And(val, IsInt32Constant(kSmiTagMask)), |
305 graph()->start())))))); | 305 graph()->start())))))); |
306 } | 306 } |
307 | 307 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 | 396 |
397 Node* val = Parameter(0); | 397 Node* val = Parameter(0); |
398 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val); | 398 Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), val); |
399 Reduction reduction = Reduce(node); | 399 Reduction reduction = Reduce(node); |
400 ASSERT_TRUE(reduction.Changed()); | 400 ASSERT_TRUE(reduction.Changed()); |
401 | 401 |
402 Node* phi = reduction.replacement(); | 402 Node* phi = reduction.replacement(); |
403 Capture<Node*> branch, if_true; | 403 Capture<Node*> branch, if_true; |
404 EXPECT_THAT( | 404 EXPECT_THAT( |
405 phi, | 405 phi, |
406 IsPhi(IsTruncateFloat64ToInt32(IsLoad( | 406 IsPhi(IsChangeFloat64ToInt32(IsLoad( |
407 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()), | 407 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()), |
408 IsControlEffect(CaptureEq(&if_true)))), | 408 IsControlEffect(CaptureEq(&if_true)))), |
409 IsTruncateInt64ToInt32( | 409 IsTruncateInt64ToInt32( |
410 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount()))), | 410 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount()))), |
411 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 411 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
412 IsIfFalse(AllOf( | 412 IsIfFalse(AllOf( |
413 CaptureEq(&branch), | 413 CaptureEq(&branch), |
414 IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), | 414 IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), |
415 graph()->start())))))); | 415 graph()->start())))))); |
416 } | 416 } |
417 | 417 |
418 | 418 |
419 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToUint32) { | 419 TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToUint32) { |
420 STATIC_ASSERT(kSmiTag == 0); | 420 STATIC_ASSERT(kSmiTag == 0); |
421 STATIC_ASSERT(kSmiTagSize == 1); | 421 STATIC_ASSERT(kSmiTagSize == 1); |
422 | 422 |
423 Node* val = Parameter(0); | 423 Node* val = Parameter(0); |
424 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val); | 424 Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), val); |
425 Reduction reduction = Reduce(node); | 425 Reduction reduction = Reduce(node); |
426 ASSERT_TRUE(reduction.Changed()); | 426 ASSERT_TRUE(reduction.Changed()); |
427 | 427 |
428 Node* phi = reduction.replacement(); | 428 Node* phi = reduction.replacement(); |
429 Capture<Node*> branch, if_true; | 429 Capture<Node*> branch, if_true; |
430 EXPECT_THAT( | 430 EXPECT_THAT( |
431 phi, | 431 phi, |
432 IsPhi(IsTruncateFloat64ToInt32(IsLoad( | 432 IsPhi(IsChangeFloat64ToUint32(IsLoad( |
433 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()), | 433 kMachFloat64, val, IsInt32Constant(HeapNumberValueOffset()), |
434 IsControlEffect(CaptureEq(&if_true)))), | 434 IsControlEffect(CaptureEq(&if_true)))), |
435 IsTruncateInt64ToInt32( | 435 IsTruncateInt64ToInt32( |
436 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount()))), | 436 IsWord64Sar(val, IsInt32Constant(SmiShiftAmount()))), |
437 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), | 437 IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))), |
438 IsIfFalse(AllOf( | 438 IsIfFalse(AllOf( |
439 CaptureEq(&branch), | 439 CaptureEq(&branch), |
440 IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), | 440 IsBranch(IsWord64And(val, IsInt32Constant(kSmiTagMask)), |
441 graph()->start())))))); | 441 graph()->start())))))); |
442 } | 442 } |
(...skipping 26 matching lines...) Expand all Loading... |
469 IsIfTrue(AllOf(CaptureEq(&branch), | 469 IsIfTrue(AllOf(CaptureEq(&branch), |
470 IsBranch(IsUint32LessThanOrEqual( | 470 IsBranch(IsUint32LessThanOrEqual( |
471 val, IsInt32Constant(SmiMaxValue())), | 471 val, IsInt32Constant(SmiMaxValue())), |
472 graph()->start()))), | 472 graph()->start()))), |
473 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); | 473 AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch)))))); |
474 } | 474 } |
475 | 475 |
476 } // namespace compiler | 476 } // namespace compiler |
477 } // namespace internal | 477 } // namespace internal |
478 } // namespace v8 | 478 } // namespace v8 |
OLD | NEW |