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

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

Issue 938513003: [x64] Recognize zero extension of 8-bit and 16-bit values. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 months 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 | « src/compiler/x64/instruction-selector-x64.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 973 matching lines...) Expand 10 before | Expand all | Expand 10 after
984 Stream s = m.Build(); 984 Stream s = m.Build();
985 ASSERT_EQ(1U, s.size()); 985 ASSERT_EQ(1U, s.size());
986 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode()); 986 EXPECT_EQ(kX64Lea32, s[0]->arch_opcode());
987 EXPECT_EQ(kMode_M8, s[0]->addressing_mode()); 987 EXPECT_EQ(kMode_M8, s[0]->addressing_mode());
988 ASSERT_EQ(1U, s[0]->InputCount()); 988 ASSERT_EQ(1U, s[0]->InputCount());
989 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 989 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
990 } 990 }
991 991
992 992
993 // ----------------------------------------------------------------------------- 993 // -----------------------------------------------------------------------------
994 // Word64Shl. 994 // Floating point operations.
995
996
997 TEST_F(InstructionSelectorTest, Float64BinopArithmetic) {
998 {
999 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64);
1000 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1));
1001 Node* mul = m.Float64Mul(add, m.Parameter(1));
1002 Node* sub = m.Float64Sub(mul, add);
1003 Node* ret = m.Float64Div(mul, sub);
1004 m.Return(ret);
1005 Stream s = m.Build(AVX);
1006 ASSERT_EQ(4U, s.size());
1007 EXPECT_EQ(kAVXFloat64Add, s[0]->arch_opcode());
1008 EXPECT_EQ(kAVXFloat64Mul, s[1]->arch_opcode());
1009 EXPECT_EQ(kAVXFloat64Sub, s[2]->arch_opcode());
1010 EXPECT_EQ(kAVXFloat64Div, s[3]->arch_opcode());
1011 }
1012 {
1013 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64);
1014 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1));
1015 Node* mul = m.Float64Mul(add, m.Parameter(1));
1016 Node* sub = m.Float64Sub(mul, add);
1017 Node* ret = m.Float64Div(mul, sub);
1018 m.Return(ret);
1019 Stream s = m.Build();
1020 ASSERT_EQ(4U, s.size());
1021 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode());
1022 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode());
1023 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode());
1024 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode());
1025 }
1026 }
1027
1028
1029 // -----------------------------------------------------------------------------
1030 // Miscellaneous.
995 1031
996 1032
997 TEST_F(InstructionSelectorTest, Word64ShlWithChangeInt32ToInt64) { 1033 TEST_F(InstructionSelectorTest, Word64ShlWithChangeInt32ToInt64) {
998 TRACED_FORRANGE(int64_t, x, 32, 63) { 1034 TRACED_FORRANGE(int64_t, x, 32, 63) {
999 StreamBuilder m(this, kMachInt64, kMachInt32); 1035 StreamBuilder m(this, kMachInt64, kMachInt32);
1000 Node* const p0 = m.Parameter(0); 1036 Node* const p0 = m.Parameter(0);
1001 Node* const n = m.Word64Shl(m.ChangeInt32ToInt64(p0), m.Int64Constant(x)); 1037 Node* const n = m.Word64Shl(m.ChangeInt32ToInt64(p0), m.Int64Constant(x));
1002 m.Return(n); 1038 m.Return(n);
1003 Stream s = m.Build(); 1039 Stream s = m.Build();
1004 ASSERT_EQ(1U, s.size()); 1040 ASSERT_EQ(1U, s.size());
(...skipping 20 matching lines...) Expand all
1025 ASSERT_EQ(2U, s[0]->InputCount()); 1061 ASSERT_EQ(2U, s[0]->InputCount());
1026 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 1062 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1027 EXPECT_EQ(x, s.ToInt32(s[0]->InputAt(1))); 1063 EXPECT_EQ(x, s.ToInt32(s[0]->InputAt(1)));
1028 ASSERT_EQ(1U, s[0]->OutputCount()); 1064 ASSERT_EQ(1U, s[0]->OutputCount());
1029 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output())); 1065 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output()));
1030 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 1066 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1031 } 1067 }
1032 } 1068 }
1033 1069
1034 1070
1035 TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { 1071 TEST_F(InstructionSelectorTest, Word32AndWith0xff) {
1036 { 1072 {
1037 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); 1073 StreamBuilder m(this, kMachInt32, kMachInt32);
1038 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); 1074 Node* const p0 = m.Parameter(0);
1039 Node* mul = m.Float64Mul(add, m.Parameter(1)); 1075 Node* const n = m.Word32And(p0, m.Int32Constant(0xff));
1040 Node* sub = m.Float64Sub(mul, add); 1076 m.Return(n);
1041 Node* ret = m.Float64Div(mul, sub); 1077 Stream s = m.Build();
1042 m.Return(ret); 1078 ASSERT_EQ(1U, s.size());
1043 Stream s = m.Build(AVX); 1079 EXPECT_EQ(kX64Movzxbl, s[0]->arch_opcode());
1044 ASSERT_EQ(4U, s.size()); 1080 ASSERT_EQ(1U, s[0]->InputCount());
1045 EXPECT_EQ(kAVXFloat64Add, s[0]->arch_opcode()); 1081 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1046 EXPECT_EQ(kAVXFloat64Mul, s[1]->arch_opcode()); 1082 ASSERT_EQ(1U, s[0]->OutputCount());
1047 EXPECT_EQ(kAVXFloat64Sub, s[2]->arch_opcode()); 1083 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1048 EXPECT_EQ(kAVXFloat64Div, s[3]->arch_opcode());
1049 } 1084 }
1050 { 1085 {
1051 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); 1086 StreamBuilder m(this, kMachInt32, kMachInt32);
1052 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); 1087 Node* const p0 = m.Parameter(0);
1053 Node* mul = m.Float64Mul(add, m.Parameter(1)); 1088 Node* const n = m.Word32And(m.Int32Constant(0xff), p0);
1054 Node* sub = m.Float64Sub(mul, add); 1089 m.Return(n);
1055 Node* ret = m.Float64Div(mul, sub);
1056 m.Return(ret);
1057 Stream s = m.Build(); 1090 Stream s = m.Build();
1058 ASSERT_EQ(4U, s.size()); 1091 ASSERT_EQ(1U, s.size());
1059 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode()); 1092 EXPECT_EQ(kX64Movzxbl, s[0]->arch_opcode());
1060 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode()); 1093 ASSERT_EQ(1U, s[0]->InputCount());
1061 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode()); 1094 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1062 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode()); 1095 ASSERT_EQ(1U, s[0]->OutputCount());
1096 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1063 } 1097 }
1064 } 1098 }
1065 1099
1100
1101 TEST_F(InstructionSelectorTest, Word32AndWith0xffff) {
1102 {
1103 StreamBuilder m(this, kMachInt32, kMachInt32);
1104 Node* const p0 = m.Parameter(0);
1105 Node* const n = m.Word32And(p0, m.Int32Constant(0xffff));
1106 m.Return(n);
1107 Stream s = m.Build();
1108 ASSERT_EQ(1U, s.size());
1109 EXPECT_EQ(kX64Movzxwl, s[0]->arch_opcode());
1110 ASSERT_EQ(1U, s[0]->InputCount());
1111 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1112 ASSERT_EQ(1U, s[0]->OutputCount());
1113 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1114 }
1115 {
1116 StreamBuilder m(this, kMachInt32, kMachInt32);
1117 Node* const p0 = m.Parameter(0);
1118 Node* const n = m.Word32And(m.Int32Constant(0xffff), p0);
1119 m.Return(n);
1120 Stream s = m.Build();
1121 ASSERT_EQ(1U, s.size());
1122 EXPECT_EQ(kX64Movzxwl, s[0]->arch_opcode());
1123 ASSERT_EQ(1U, s[0]->InputCount());
1124 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1125 ASSERT_EQ(1U, s[0]->OutputCount());
1126 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1127 }
1128 }
1129
1066 } // namespace compiler 1130 } // namespace compiler
1067 } // namespace internal 1131 } // namespace internal
1068 } // namespace v8 1132 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698