| 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 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 628 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 628 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 629 EXPECT_TRUE(s.IsFixed(s[0]->InputAt(0), eax)); | 629 EXPECT_TRUE(s.IsFixed(s[0]->InputAt(0), eax)); |
| 630 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); | 630 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); |
| 631 EXPECT_TRUE(!s.IsUsedAtStart(s[0]->InputAt(1))); | 631 EXPECT_TRUE(!s.IsUsedAtStart(s[0]->InputAt(1))); |
| 632 ASSERT_EQ(1U, s[0]->OutputCount()); | 632 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 633 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 633 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 634 EXPECT_TRUE(s.IsFixed(s[0]->OutputAt(0), edx)); | 634 EXPECT_TRUE(s.IsFixed(s[0]->OutputAt(0), edx)); |
| 635 } | 635 } |
| 636 | 636 |
| 637 | 637 |
| 638 // ----------------------------------------------------------------------------- |
| 639 // Floating point operations. |
| 640 |
| 641 |
| 638 TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { | 642 TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { |
| 639 { | 643 { |
| 640 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); | 644 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); |
| 641 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); | 645 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); |
| 642 Node* mul = m.Float64Mul(add, m.Parameter(1)); | 646 Node* mul = m.Float64Mul(add, m.Parameter(1)); |
| 643 Node* sub = m.Float64Sub(mul, add); | 647 Node* sub = m.Float64Sub(mul, add); |
| 644 Node* ret = m.Float64Div(mul, sub); | 648 Node* ret = m.Float64Div(mul, sub); |
| 645 m.Return(ret); | 649 m.Return(ret); |
| 646 Stream s = m.Build(AVX); | 650 Stream s = m.Build(AVX); |
| 647 ASSERT_EQ(4U, s.size()); | 651 ASSERT_EQ(4U, s.size()); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 660 Stream s = m.Build(); | 664 Stream s = m.Build(); |
| 661 ASSERT_EQ(4U, s.size()); | 665 ASSERT_EQ(4U, s.size()); |
| 662 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode()); | 666 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode()); |
| 663 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode()); | 667 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode()); |
| 664 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode()); | 668 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode()); |
| 665 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode()); | 669 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode()); |
| 666 } | 670 } |
| 667 } | 671 } |
| 668 | 672 |
| 669 | 673 |
| 674 TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) { |
| 675 StreamBuilder m(this, kMachFloat32, kMachFloat32); |
| 676 Node* const p0 = m.Parameter(0); |
| 677 Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); |
| 678 m.Return(n); |
| 679 Stream s = m.Build(); |
| 680 ASSERT_EQ(1U, s.size()); |
| 681 EXPECT_EQ(kSSEFloat32Neg, s[0]->arch_opcode()); |
| 682 ASSERT_EQ(1U, s[0]->InputCount()); |
| 683 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 684 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 685 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 686 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 687 } |
| 688 |
| 689 |
| 690 TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { |
| 691 StreamBuilder m(this, kMachFloat64, kMachFloat64); |
| 692 Node* const p0 = m.Parameter(0); |
| 693 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); |
| 694 m.Return(n); |
| 695 Stream s = m.Build(); |
| 696 ASSERT_EQ(1U, s.size()); |
| 697 EXPECT_EQ(kSSEFloat64Neg, s[0]->arch_opcode()); |
| 698 ASSERT_EQ(1U, s[0]->InputCount()); |
| 699 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 700 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 701 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 702 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 703 } |
| 704 |
| 705 |
| 670 // ----------------------------------------------------------------------------- | 706 // ----------------------------------------------------------------------------- |
| 671 // Miscellaneous. | 707 // Miscellaneous. |
| 672 | 708 |
| 673 | 709 |
| 674 TEST_F(InstructionSelectorTest, Uint32LessThanWithLoadAndLoadStackPointer) { | 710 TEST_F(InstructionSelectorTest, Uint32LessThanWithLoadAndLoadStackPointer) { |
| 675 StreamBuilder m(this, kMachBool); | 711 StreamBuilder m(this, kMachBool); |
| 676 Node* const sl = m.Load( | 712 Node* const sl = m.Load( |
| 677 kMachPtr, | 713 kMachPtr, |
| 678 m.ExternalConstant(ExternalReference::address_of_stack_limit(isolate()))); | 714 m.ExternalConstant(ExternalReference::address_of_stack_limit(isolate()))); |
| 679 Node* const sp = m.LoadStackPointer(); | 715 Node* const sp = m.LoadStackPointer(); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 700 EXPECT_EQ(kIA32Lzcnt, s[0]->arch_opcode()); | 736 EXPECT_EQ(kIA32Lzcnt, s[0]->arch_opcode()); |
| 701 ASSERT_EQ(1U, s[0]->InputCount()); | 737 ASSERT_EQ(1U, s[0]->InputCount()); |
| 702 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 738 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 703 ASSERT_EQ(1U, s[0]->OutputCount()); | 739 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 704 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 740 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 705 } | 741 } |
| 706 | 742 |
| 707 } // namespace compiler | 743 } // namespace compiler |
| 708 } // namespace internal | 744 } // namespace internal |
| 709 } // namespace v8 | 745 } // namespace v8 |
| OLD | NEW |