| 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 "test/unittests/compiler/instruction-selector-unittest.h" | 5 #include "test/unittests/compiler/instruction-selector-unittest.h" |
| 6 | 6 |
| 7 namespace v8 { | 7 namespace v8 { |
| 8 namespace internal { | 8 namespace internal { |
| 9 namespace compiler { | 9 namespace compiler { |
| 10 | 10 |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 m.Return(ret); | 744 m.Return(ret); |
| 745 Stream s = m.Build(); | 745 Stream s = m.Build(); |
| 746 ASSERT_EQ(4U, s.size()); | 746 ASSERT_EQ(4U, s.size()); |
| 747 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode()); | 747 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode()); |
| 748 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode()); | 748 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode()); |
| 749 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode()); | 749 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode()); |
| 750 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode()); | 750 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode()); |
| 751 } | 751 } |
| 752 } | 752 } |
| 753 | 753 |
| 754 | |
| 755 TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) { | |
| 756 { | |
| 757 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); | |
| 758 Node* const p0 = m.Parameter(0); | |
| 759 Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); | |
| 760 m.Return(n); | |
| 761 Stream s = m.Build(); | |
| 762 ASSERT_EQ(1U, s.size()); | |
| 763 EXPECT_EQ(kSSEFloat32Neg, s[0]->arch_opcode()); | |
| 764 ASSERT_EQ(1U, s[0]->InputCount()); | |
| 765 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | |
| 766 ASSERT_EQ(1U, s[0]->OutputCount()); | |
| 767 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | |
| 768 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | |
| 769 } | |
| 770 { | |
| 771 StreamBuilder m(this, MachineType::Float32(), MachineType::Float32()); | |
| 772 Node* const p0 = m.Parameter(0); | |
| 773 Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); | |
| 774 m.Return(n); | |
| 775 Stream s = m.Build(AVX); | |
| 776 ASSERT_EQ(1U, s.size()); | |
| 777 EXPECT_EQ(kAVXFloat32Neg, s[0]->arch_opcode()); | |
| 778 ASSERT_EQ(1U, s[0]->InputCount()); | |
| 779 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | |
| 780 ASSERT_EQ(1U, s[0]->OutputCount()); | |
| 781 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | |
| 782 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | |
| 783 } | |
| 784 } | |
| 785 | |
| 786 | |
| 787 TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { | |
| 788 { | |
| 789 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); | |
| 790 Node* const p0 = m.Parameter(0); | |
| 791 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); | |
| 792 m.Return(n); | |
| 793 Stream s = m.Build(); | |
| 794 ASSERT_EQ(1U, s.size()); | |
| 795 EXPECT_EQ(kSSEFloat64Neg, s[0]->arch_opcode()); | |
| 796 ASSERT_EQ(1U, s[0]->InputCount()); | |
| 797 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | |
| 798 ASSERT_EQ(1U, s[0]->OutputCount()); | |
| 799 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | |
| 800 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | |
| 801 } | |
| 802 { | |
| 803 StreamBuilder m(this, MachineType::Float64(), MachineType::Float64()); | |
| 804 Node* const p0 = m.Parameter(0); | |
| 805 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); | |
| 806 m.Return(n); | |
| 807 Stream s = m.Build(AVX); | |
| 808 ASSERT_EQ(1U, s.size()); | |
| 809 EXPECT_EQ(kAVXFloat64Neg, s[0]->arch_opcode()); | |
| 810 ASSERT_EQ(1U, s[0]->InputCount()); | |
| 811 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | |
| 812 ASSERT_EQ(1U, s[0]->OutputCount()); | |
| 813 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | |
| 814 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | |
| 815 } | |
| 816 } | |
| 817 | |
| 818 | |
| 819 // ----------------------------------------------------------------------------- | 754 // ----------------------------------------------------------------------------- |
| 820 // Miscellaneous. | 755 // Miscellaneous. |
| 821 | 756 |
| 822 | 757 |
| 823 TEST_F(InstructionSelectorTest, Uint32LessThanWithLoadAndLoadStackPointer) { | 758 TEST_F(InstructionSelectorTest, Uint32LessThanWithLoadAndLoadStackPointer) { |
| 824 StreamBuilder m(this, MachineType::Bool()); | 759 StreamBuilder m(this, MachineType::Bool()); |
| 825 Node* const sl = m.Load( | 760 Node* const sl = m.Load( |
| 826 MachineType::Pointer(), | 761 MachineType::Pointer(), |
| 827 m.ExternalConstant(ExternalReference::address_of_stack_limit(isolate()))); | 762 m.ExternalConstant(ExternalReference::address_of_stack_limit(isolate()))); |
| 828 Node* const sp = m.LoadStackPointer(); | 763 Node* const sp = m.LoadStackPointer(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 849 EXPECT_EQ(kIA32Lzcnt, s[0]->arch_opcode()); | 784 EXPECT_EQ(kIA32Lzcnt, s[0]->arch_opcode()); |
| 850 ASSERT_EQ(1U, s[0]->InputCount()); | 785 ASSERT_EQ(1U, s[0]->InputCount()); |
| 851 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 786 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 852 ASSERT_EQ(1U, s[0]->OutputCount()); | 787 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 853 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 788 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 854 } | 789 } |
| 855 | 790 |
| 856 } // namespace compiler | 791 } // namespace compiler |
| 857 } // namespace internal | 792 } // namespace internal |
| 858 } // namespace v8 | 793 } // namespace v8 |
| OLD | NEW |