Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: test/unittests/compiler/x64/instruction-selector-x64-unittest.cc

Issue 756643002: [turbofan] Fix lea matching. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Unit test & fix Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/regress/regress-lea-matching.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 723 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 Stream s = m.Build(); 734 Stream s = m.Build();
735 ASSERT_EQ(2U, s.size()); 735 ASSERT_EQ(2U, s.size());
736 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode()); 736 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
737 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode()); 737 EXPECT_EQ(kMode_MRI, s[0]->addressing_mode());
738 ASSERT_EQ(2U, s[0]->InputCount()); 738 ASSERT_EQ(2U, s[0]->InputCount());
739 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 739 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
740 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate()); 740 EXPECT_TRUE(s[0]->InputAt(1)->IsImmediate());
741 } 741 }
742 742
743 743
744 TEST_F(InstructionSelectorTest, Int32AddScaled2Other) {
745 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
746 Node* const p0 = m.Parameter(0);
747 Node* const p1 = m.Parameter(1);
748 Node* const p2 = m.Parameter(2);
749 Node* const s0 = m.Int32Mul(p1, m.Int32Constant(2));
750 Node* const a0 = m.Int32Add(s0, p2);
751 Node* const a1 = m.Int32Add(p0, a0);
752 m.Return(a1);
753 Stream s = m.Build();
754 ASSERT_EQ(2U, s.size());
755 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
756 EXPECT_EQ(kMode_MR2, s[0]->addressing_mode());
757 ASSERT_EQ(2U, s[0]->InputCount());
758 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(0)));
759 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
760 EXPECT_EQ(s.ToVreg(a0), s.ToVreg(s[0]->OutputAt(0)));
761 ASSERT_EQ(2U, s[1]->InputCount());
762 EXPECT_EQ(kX64Add32, s[1]->arch_opcode());
763 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[1]->InputAt(0)));
764 EXPECT_EQ(s.ToVreg(a0), s.ToVreg(s[1]->InputAt(1)));
765 EXPECT_EQ(s.ToVreg(a1), s.ToVreg(s[1]->OutputAt(0)));
766 }
767
768
744 // ----------------------------------------------------------------------------- 769 // -----------------------------------------------------------------------------
745 // Multiplication. 770 // Multiplication.
746 771
747 772
748 TEST_F(InstructionSelectorTest, Int32MulWithInt32MulWithParameters) { 773 TEST_F(InstructionSelectorTest, Int32MulWithInt32MulWithParameters) {
749 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 774 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
750 Node* const p0 = m.Parameter(0); 775 Node* const p0 = m.Parameter(0);
751 Node* const p1 = m.Parameter(1); 776 Node* const p1 = m.Parameter(1);
752 Node* const m0 = m.Int32Mul(p0, p1); 777 Node* const m0 = m.Int32Mul(p0, p1);
753 m.Return(m.Int32Mul(m0, p0)); 778 m.Return(m.Int32Mul(m0, p0));
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
843 EXPECT_EQ(x, s.ToInt32(s[0]->InputAt(1))); 868 EXPECT_EQ(x, s.ToInt32(s[0]->InputAt(1)));
844 ASSERT_EQ(1U, s[0]->OutputCount()); 869 ASSERT_EQ(1U, s[0]->OutputCount());
845 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output())); 870 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output()));
846 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 871 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
847 } 872 }
848 } 873 }
849 874
850 } // namespace compiler 875 } // namespace compiler
851 } // namespace internal 876 } // namespace internal
852 } // namespace v8 877 } // namespace v8
OLDNEW
« no previous file with comments | « test/mjsunit/regress/regress-lea-matching.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698