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/machine-operator-reducer.h" | 5 #include "src/compiler/machine-operator-reducer.h" |
6 #include "src/base/bits.h" | 6 #include "src/base/bits.h" |
7 #include "src/base/division-by-constant.h" | 7 #include "src/base/division-by-constant.h" |
8 #include "src/base/ieee754.h" | 8 #include "src/base/ieee754.h" |
9 #include "src/compiler/js-graph.h" | 9 #include "src/compiler/js-graph.h" |
10 #include "src/compiler/typer.h" | 10 #include "src/compiler/typer.h" |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
843 machine()->Word32Sar(), | 843 machine()->Word32Sar(), |
844 graph()->NewNode(machine()->Word32Shl(), l, Int32Constant(16)), | 844 graph()->NewNode(machine()->Word32Shl(), l, Int32Constant(16)), |
845 Int32Constant(16))); | 845 Int32Constant(16))); |
846 ASSERT_TRUE(r.Changed()); | 846 ASSERT_TRUE(r.Changed()); |
847 EXPECT_EQ(l, r.replacement()); | 847 EXPECT_EQ(l, r.replacement()); |
848 } | 848 } |
849 } | 849 } |
850 | 850 |
851 | 851 |
852 // ----------------------------------------------------------------------------- | 852 // ----------------------------------------------------------------------------- |
| 853 // Word32Shr |
| 854 |
| 855 TEST_F(MachineOperatorReducerTest, Word32ShrWithWord32And) { |
| 856 Node* const p0 = Parameter(0); |
| 857 TRACED_FORRANGE(int32_t, shift, 1, 31) { |
| 858 uint32_t mask = (1 << shift) - 1; |
| 859 Node* node = graph()->NewNode( |
| 860 machine()->Word32Shr(), |
| 861 graph()->NewNode(machine()->Word32And(), p0, Int32Constant(mask)), |
| 862 Int32Constant(shift)); |
| 863 Reduction r = Reduce(node); |
| 864 ASSERT_TRUE(r.Changed()); |
| 865 EXPECT_THAT(r.replacement(), IsInt32Constant(0)); |
| 866 } |
| 867 } |
| 868 |
| 869 // ----------------------------------------------------------------------------- |
853 // Word32Shl | 870 // Word32Shl |
854 | 871 |
855 | |
856 TEST_F(MachineOperatorReducerTest, Word32ShlWithZeroShift) { | 872 TEST_F(MachineOperatorReducerTest, Word32ShlWithZeroShift) { |
857 Node* p0 = Parameter(0); | 873 Node* p0 = Parameter(0); |
858 Node* node = graph()->NewNode(machine()->Word32Shl(), p0, Int32Constant(0)); | 874 Node* node = graph()->NewNode(machine()->Word32Shl(), p0, Int32Constant(0)); |
859 Reduction r = Reduce(node); | 875 Reduction r = Reduce(node); |
860 ASSERT_TRUE(r.Changed()); | 876 ASSERT_TRUE(r.Changed()); |
861 EXPECT_EQ(p0, r.replacement()); | 877 EXPECT_EQ(p0, r.replacement()); |
862 } | 878 } |
863 | 879 |
864 | 880 |
865 TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Sar) { | 881 TEST_F(MachineOperatorReducerTest, Word32ShlWithWord32Sar) { |
(...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1718 Reduction r = Reduce(node); | 1734 Reduction r = Reduce(node); |
1719 ASSERT_TRUE(r.Changed()); | 1735 ASSERT_TRUE(r.Changed()); |
1720 EXPECT_THAT(r.replacement(), | 1736 EXPECT_THAT(r.replacement(), |
1721 IsStore(rep, base, index, value, effect, control)); | 1737 IsStore(rep, base, index, value, effect, control)); |
1722 } | 1738 } |
1723 } | 1739 } |
1724 | 1740 |
1725 } // namespace compiler | 1741 } // namespace compiler |
1726 } // namespace internal | 1742 } // namespace internal |
1727 } // namespace v8 | 1743 } // namespace v8 |
OLD | NEW |