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

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

Issue 774193003: [turbofan] Use "leal" in even more situations (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@765983002
Patch Set: Fix Windows 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/unittests/compiler/node-matchers-unittest.cc ('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 828 matching lines...) Expand 10 before | Expand all | Expand 10 after
839 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 839 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
840 EXPECT_TRUE(s.IsFixed(s[0]->InputAt(0), rax)); 840 EXPECT_TRUE(s.IsFixed(s[0]->InputAt(0), rax));
841 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1))); 841 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
842 EXPECT_TRUE(!s.IsUsedAtStart(s[0]->InputAt(1))); 842 EXPECT_TRUE(!s.IsUsedAtStart(s[0]->InputAt(1)));
843 ASSERT_LE(1U, s[0]->OutputCount()); 843 ASSERT_LE(1U, s[0]->OutputCount());
844 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 844 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
845 EXPECT_TRUE(s.IsFixed(s[0]->OutputAt(0), rdx)); 845 EXPECT_TRUE(s.IsFixed(s[0]->OutputAt(0), rdx));
846 } 846 }
847 847
848 848
849 TEST_F(InstructionSelectorTest, Int32Mul2BecomesLea) {
850 StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32);
851 Node* const p0 = m.Parameter(0);
852 Node* const c1 = m.Int32Constant(2);
853 Node* const n = m.Int32Mul(p0, c1);
854 m.Return(n);
855 Stream s = m.Build();
856 ASSERT_EQ(1U, s.size());
857 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
858 EXPECT_EQ(kMode_MR1, s[0]->addressing_mode());
859 ASSERT_EQ(2U, s[0]->InputCount());
860 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
861 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
862 }
863
864
865 TEST_F(InstructionSelectorTest, Int32Mul3BecomesLea) {
866 StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32);
867 Node* const p0 = m.Parameter(0);
868 Node* const c1 = m.Int32Constant(3);
869 Node* const n = m.Int32Mul(p0, c1);
870 m.Return(n);
871 Stream s = m.Build();
872 ASSERT_EQ(1U, s.size());
873 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
874 EXPECT_EQ(kMode_MR2, s[0]->addressing_mode());
875 ASSERT_EQ(2U, s[0]->InputCount());
876 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
877 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
878 }
879
880
881 TEST_F(InstructionSelectorTest, Int32Mul4BecomesLea) {
882 StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32);
883 Node* const p0 = m.Parameter(0);
884 Node* const c1 = m.Int32Constant(4);
885 Node* const n = m.Int32Mul(p0, c1);
886 m.Return(n);
887 Stream s = m.Build();
888 ASSERT_EQ(1U, s.size());
889 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
890 EXPECT_EQ(kMode_M4, s[0]->addressing_mode());
891 ASSERT_EQ(1U, s[0]->InputCount());
892 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
893 }
894
895
896 TEST_F(InstructionSelectorTest, Int32Mul5BecomesLea) {
897 StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32);
898 Node* const p0 = m.Parameter(0);
899 Node* const c1 = m.Int32Constant(5);
900 Node* const n = m.Int32Mul(p0, c1);
901 m.Return(n);
902 Stream s = m.Build();
903 ASSERT_EQ(1U, s.size());
904 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
905 EXPECT_EQ(kMode_MR4, s[0]->addressing_mode());
906 ASSERT_EQ(2U, s[0]->InputCount());
907 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
908 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
909 }
910
911
912 TEST_F(InstructionSelectorTest, Int32Mul8BecomesLea) {
913 StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32);
914 Node* const p0 = m.Parameter(0);
915 Node* const c1 = m.Int32Constant(8);
916 Node* const n = m.Int32Mul(p0, c1);
917 m.Return(n);
918 Stream s = m.Build();
919 ASSERT_EQ(1U, s.size());
920 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
921 EXPECT_EQ(kMode_M8, s[0]->addressing_mode());
922 ASSERT_EQ(1U, s[0]->InputCount());
923 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
924 }
925
926
927 TEST_F(InstructionSelectorTest, Int32Mul9BecomesLea) {
928 StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32);
929 Node* const p0 = m.Parameter(0);
930 Node* const c1 = m.Int32Constant(9);
931 Node* const n = m.Int32Mul(p0, c1);
932 m.Return(n);
933 Stream s = m.Build();
934 ASSERT_EQ(1U, s.size());
935 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
936 EXPECT_EQ(kMode_MR8, s[0]->addressing_mode());
937 ASSERT_EQ(2U, s[0]->InputCount());
938 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
939 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
940 }
941
942
943 // -----------------------------------------------------------------------------
944 // Word32Shl.
945
946
947 TEST_F(InstructionSelectorTest, Int32Shl1BecomesLea) {
948 StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32);
949 Node* const p0 = m.Parameter(0);
950 Node* const c1 = m.Int32Constant(1);
951 Node* const n = m.Word32Shl(p0, c1);
952 m.Return(n);
953 Stream s = m.Build();
954 ASSERT_EQ(1U, s.size());
955 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
956 EXPECT_EQ(kMode_MR1, s[0]->addressing_mode());
957 ASSERT_EQ(2U, s[0]->InputCount());
958 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
959 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
960 }
961
962
963 TEST_F(InstructionSelectorTest, Int32Shl2BecomesLea) {
964 StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32);
965 Node* const p0 = m.Parameter(0);
966 Node* const c1 = m.Int32Constant(2);
967 Node* const n = m.Word32Shl(p0, c1);
968 m.Return(n);
969 Stream s = m.Build();
970 ASSERT_EQ(1U, s.size());
971 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
972 EXPECT_EQ(kMode_M4, s[0]->addressing_mode());
973 ASSERT_EQ(1U, s[0]->InputCount());
974 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
975 }
976
977
978 TEST_F(InstructionSelectorTest, Int32Shl4BecomesLea) {
979 StreamBuilder m(this, kMachUint32, kMachUint32, kMachUint32);
980 Node* const p0 = m.Parameter(0);
981 Node* const c1 = m.Int32Constant(3);
982 Node* const n = m.Word32Shl(p0, c1);
983 m.Return(n);
984 Stream s = m.Build();
985 ASSERT_EQ(1U, s.size());
986 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
987 EXPECT_EQ(kMode_M8, s[0]->addressing_mode());
988 ASSERT_EQ(1U, s[0]->InputCount());
989 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
990 }
991
992
849 // ----------------------------------------------------------------------------- 993 // -----------------------------------------------------------------------------
850 // Word64Shl. 994 // Word64Shl.
851 995
852 996
853 TEST_F(InstructionSelectorTest, Word64ShlWithChangeInt32ToInt64) { 997 TEST_F(InstructionSelectorTest, Word64ShlWithChangeInt32ToInt64) {
854 TRACED_FORRANGE(int64_t, x, 32, 63) { 998 TRACED_FORRANGE(int64_t, x, 32, 63) {
855 StreamBuilder m(this, kMachInt64, kMachInt32); 999 StreamBuilder m(this, kMachInt64, kMachInt32);
856 Node* const p0 = m.Parameter(0); 1000 Node* const p0 = m.Parameter(0);
857 Node* const n = m.Word64Shl(m.ChangeInt32ToInt64(p0), m.Int64Constant(x)); 1001 Node* const n = m.Word64Shl(m.ChangeInt32ToInt64(p0), m.Int64Constant(x));
858 m.Return(n); 1002 m.Return(n);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode()); 1059 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode());
916 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode()); 1060 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode());
917 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode()); 1061 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode());
918 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode()); 1062 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode());
919 } 1063 }
920 } 1064 }
921 1065
922 } // namespace compiler 1066 } // namespace compiler
923 } // namespace internal 1067 } // namespace internal
924 } // namespace v8 1068 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/node-matchers-unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698