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/base/bits.h" | 5 #include "src/base/bits.h" |
6 #include "src/base/division-by-constant.h" | 6 #include "src/base/division-by-constant.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/machine-operator-reducer.h" | 8 #include "src/compiler/machine-operator-reducer.h" |
9 #include "src/compiler/typer.h" | 9 #include "src/compiler/typer.h" |
10 #include "test/unittests/compiler/graph-unittest.h" | 10 #include "test/unittests/compiler/graph-unittest.h" |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 Reduction reduction = Reduce(node); | 638 Reduction reduction = Reduce(node); |
639 EXPECT_TRUE(reduction.Changed()); | 639 EXPECT_TRUE(reduction.Changed()); |
640 EXPECT_THAT(reduction.replacement(), | 640 EXPECT_THAT(reduction.replacement(), |
641 IsInt32Constant(base::bits::RotateRight32(x, y))); | 641 IsInt32Constant(base::bits::RotateRight32(x, y))); |
642 } | 642 } |
643 } | 643 } |
644 } | 644 } |
645 | 645 |
646 | 646 |
647 // ----------------------------------------------------------------------------- | 647 // ----------------------------------------------------------------------------- |
| 648 // Word32Sar |
| 649 |
| 650 |
| 651 TEST_F(MachineOperatorReducerTest, Word32SarWithWord32ShlAndLoad) { |
| 652 Node* const p0 = Parameter(0); |
| 653 Node* const p1 = Parameter(1); |
| 654 { |
| 655 Node* const l = graph()->NewNode(machine()->Load(kMachInt8), p0, p1, |
| 656 graph()->start(), graph()->start()); |
| 657 Reduction const r = Reduce(graph()->NewNode( |
| 658 machine()->Word32Sar(), |
| 659 graph()->NewNode(machine()->Word32Shl(), l, Int32Constant(24)), |
| 660 Int32Constant(24))); |
| 661 ASSERT_TRUE(r.Changed()); |
| 662 EXPECT_EQ(l, r.replacement()); |
| 663 } |
| 664 { |
| 665 Node* const l = graph()->NewNode(machine()->Load(kMachInt16), p0, p1, |
| 666 graph()->start(), graph()->start()); |
| 667 Reduction const r = Reduce(graph()->NewNode( |
| 668 machine()->Word32Sar(), |
| 669 graph()->NewNode(machine()->Word32Shl(), l, Int32Constant(16)), |
| 670 Int32Constant(16))); |
| 671 ASSERT_TRUE(r.Changed()); |
| 672 EXPECT_EQ(l, r.replacement()); |
| 673 } |
| 674 } |
| 675 |
| 676 |
| 677 // ----------------------------------------------------------------------------- |
648 // Word32Shl | 678 // Word32Shl |
649 | 679 |
650 | 680 |
651 TEST_F(MachineOperatorReducerTest, Word32ShlWithZeroShift) { | 681 TEST_F(MachineOperatorReducerTest, Word32ShlWithZeroShift) { |
652 Node* p0 = Parameter(0); | 682 Node* p0 = Parameter(0); |
653 Node* node = graph()->NewNode(machine()->Word32Shl(), p0, Int32Constant(0)); | 683 Node* node = graph()->NewNode(machine()->Word32Shl(), p0, Int32Constant(0)); |
654 Reduction r = Reduce(node); | 684 Reduction r = Reduce(node); |
655 ASSERT_TRUE(r.Changed()); | 685 ASSERT_TRUE(r.Changed()); |
656 EXPECT_EQ(p0, r.replacement()); | 686 EXPECT_EQ(p0, r.replacement()); |
657 } | 687 } |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1218 Reduction r = Reduce(node); | 1248 Reduction r = Reduce(node); |
1219 ASSERT_TRUE(r.Changed()); | 1249 ASSERT_TRUE(r.Changed()); |
1220 EXPECT_THAT(r.replacement(), | 1250 EXPECT_THAT(r.replacement(), |
1221 IsStore(rep, base, index, value, effect, control)); | 1251 IsStore(rep, base, index, value, effect, control)); |
1222 } | 1252 } |
1223 } | 1253 } |
1224 | 1254 |
1225 } // namespace compiler | 1255 } // namespace compiler |
1226 } // namespace internal | 1256 } // namespace internal |
1227 } // namespace v8 | 1257 } // namespace v8 |
OLD | NEW |