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/js-graph.h" | 5 #include "src/compiler/js-graph.h" |
6 #include "src/compiler/simplified-operator.h" | 6 #include "src/compiler/simplified-operator.h" |
7 #include "src/compiler/simplified-operator-reducer.h" | 7 #include "src/compiler/simplified-operator-reducer.h" |
8 #include "src/compiler/typer.h" | 8 #include "src/compiler/typer.h" |
9 #include "src/conversions.h" | 9 #include "src/conversions.h" |
10 #include "test/compiler-unittests/graph-unittest.h" | 10 #include "test/compiler-unittests/graph-unittest.h" |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 // ChangeTaggedToInt32 | 357 // ChangeTaggedToInt32 |
358 | 358 |
359 | 359 |
360 TEST_F(SimplifiedOperatorReducerTest, | 360 TEST_F(SimplifiedOperatorReducerTest, |
361 ChangeTaggedToInt32WithChangeFloat64ToTagged) { | 361 ChangeTaggedToInt32WithChangeFloat64ToTagged) { |
362 Node* param0 = Parameter(0); | 362 Node* param0 = Parameter(0); |
363 Reduction reduction = Reduce(graph()->NewNode( | 363 Reduction reduction = Reduce(graph()->NewNode( |
364 simplified()->ChangeTaggedToInt32(), | 364 simplified()->ChangeTaggedToInt32(), |
365 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0))); | 365 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0))); |
366 ASSERT_TRUE(reduction.Changed()); | 366 ASSERT_TRUE(reduction.Changed()); |
367 EXPECT_THAT(reduction.replacement(), IsTruncateFloat64ToInt32(param0)); | 367 EXPECT_THAT(reduction.replacement(), IsChangeFloat64ToInt32(param0)); |
368 } | 368 } |
369 | 369 |
370 | 370 |
371 TEST_F(SimplifiedOperatorReducerTest, | 371 TEST_F(SimplifiedOperatorReducerTest, |
372 ChangeTaggedToInt32WithChangeInt32ToTagged) { | 372 ChangeTaggedToInt32WithChangeInt32ToTagged) { |
373 Node* param0 = Parameter(0); | 373 Node* param0 = Parameter(0); |
374 Reduction reduction = Reduce(graph()->NewNode( | 374 Reduction reduction = Reduce(graph()->NewNode( |
375 simplified()->ChangeTaggedToInt32(), | 375 simplified()->ChangeTaggedToInt32(), |
376 graph()->NewNode(simplified()->ChangeInt32ToTagged(), param0))); | 376 graph()->NewNode(simplified()->ChangeInt32ToTagged(), param0))); |
377 ASSERT_TRUE(reduction.Changed()); | 377 ASSERT_TRUE(reduction.Changed()); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 // ChangeTaggedToUint32 | 411 // ChangeTaggedToUint32 |
412 | 412 |
413 | 413 |
414 TEST_F(SimplifiedOperatorReducerTest, | 414 TEST_F(SimplifiedOperatorReducerTest, |
415 ChangeTaggedToUint32WithChangeFloat64ToTagged) { | 415 ChangeTaggedToUint32WithChangeFloat64ToTagged) { |
416 Node* param0 = Parameter(0); | 416 Node* param0 = Parameter(0); |
417 Reduction reduction = Reduce(graph()->NewNode( | 417 Reduction reduction = Reduce(graph()->NewNode( |
418 simplified()->ChangeTaggedToUint32(), | 418 simplified()->ChangeTaggedToUint32(), |
419 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0))); | 419 graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0))); |
420 ASSERT_TRUE(reduction.Changed()); | 420 ASSERT_TRUE(reduction.Changed()); |
421 EXPECT_THAT(reduction.replacement(), IsTruncateFloat64ToInt32(param0)); | 421 EXPECT_THAT(reduction.replacement(), IsChangeFloat64ToUint32(param0)); |
422 } | 422 } |
423 | 423 |
424 | 424 |
425 TEST_F(SimplifiedOperatorReducerTest, | 425 TEST_F(SimplifiedOperatorReducerTest, |
426 ChangeTaggedToUint32WithChangeUint32ToTagged) { | 426 ChangeTaggedToUint32WithChangeUint32ToTagged) { |
427 Node* param0 = Parameter(0); | 427 Node* param0 = Parameter(0); |
428 Reduction reduction = Reduce(graph()->NewNode( | 428 Reduction reduction = Reduce(graph()->NewNode( |
429 simplified()->ChangeTaggedToUint32(), | 429 simplified()->ChangeTaggedToUint32(), |
430 graph()->NewNode(simplified()->ChangeUint32ToTagged(), param0))); | 430 graph()->NewNode(simplified()->ChangeUint32ToTagged(), param0))); |
431 ASSERT_TRUE(reduction.Changed()); | 431 ASSERT_TRUE(reduction.Changed()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), | 472 Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), |
473 Int32Constant(BitCast<int32_t>(n)))); | 473 Int32Constant(BitCast<int32_t>(n)))); |
474 ASSERT_TRUE(reduction.Changed()); | 474 ASSERT_TRUE(reduction.Changed()); |
475 EXPECT_THAT(reduction.replacement(), IsNumberConstant(FastUI2D(n))); | 475 EXPECT_THAT(reduction.replacement(), IsNumberConstant(FastUI2D(n))); |
476 } | 476 } |
477 } | 477 } |
478 | 478 |
479 } // namespace compiler | 479 } // namespace compiler |
480 } // namespace internal | 480 } // namespace internal |
481 } // namespace v8 | 481 } // namespace v8 |
OLD | NEW |