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 #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 979 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
990 ASSERT_EQ(1U, s[0]->InputCount()); | 990 ASSERT_EQ(1U, s[0]->InputCount()); |
991 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 991 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
992 } | 992 } |
993 | 993 |
994 | 994 |
995 // ----------------------------------------------------------------------------- | 995 // ----------------------------------------------------------------------------- |
996 // Floating point operations. | 996 // Floating point operations. |
997 | 997 |
998 | 998 |
999 TEST_F(InstructionSelectorTest, Float32Abs) { | 999 TEST_F(InstructionSelectorTest, Float32Abs) { |
1000 StreamBuilder m(this, kMachFloat32, kMachFloat32); | 1000 { |
1001 Node* const p0 = m.Parameter(0); | 1001 StreamBuilder m(this, kMachFloat32, kMachFloat32); |
1002 Node* const n = m.Float32Abs(p0); | 1002 Node* const p0 = m.Parameter(0); |
1003 m.Return(n); | 1003 Node* const n = m.Float32Abs(p0); |
1004 Stream s = m.Build(); | 1004 m.Return(n); |
1005 ASSERT_EQ(1U, s.size()); | 1005 Stream s = m.Build(); |
1006 EXPECT_EQ(kSSEFloat32Abs, s[0]->arch_opcode()); | 1006 ASSERT_EQ(1U, s.size()); |
1007 ASSERT_EQ(1U, s[0]->InputCount()); | 1007 EXPECT_EQ(kSSEFloat32Abs, s[0]->arch_opcode()); |
1008 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1008 ASSERT_EQ(1U, s[0]->InputCount()); |
1009 ASSERT_EQ(1U, s[0]->OutputCount()); | 1009 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
1010 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output())); | 1010 ASSERT_EQ(1U, s[0]->OutputCount()); |
1011 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1011 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output())); |
1012 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1012 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1013 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1014 } |
| 1015 { |
| 1016 StreamBuilder m(this, kMachFloat32, kMachFloat32); |
| 1017 Node* const p0 = m.Parameter(0); |
| 1018 Node* const n = m.Float32Abs(p0); |
| 1019 m.Return(n); |
| 1020 Stream s = m.Build(AVX); |
| 1021 ASSERT_EQ(1U, s.size()); |
| 1022 EXPECT_EQ(kAVXFloat32Abs, s[0]->arch_opcode()); |
| 1023 ASSERT_EQ(1U, s[0]->InputCount()); |
| 1024 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1025 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1026 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1027 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1028 } |
1013 } | 1029 } |
1014 | 1030 |
1015 | 1031 |
1016 TEST_F(InstructionSelectorTest, Float64Abs) { | 1032 TEST_F(InstructionSelectorTest, Float64Abs) { |
1017 StreamBuilder m(this, kMachFloat64, kMachFloat64); | 1033 { |
1018 Node* const p0 = m.Parameter(0); | 1034 StreamBuilder m(this, kMachFloat64, kMachFloat64); |
1019 Node* const n = m.Float64Abs(p0); | 1035 Node* const p0 = m.Parameter(0); |
1020 m.Return(n); | 1036 Node* const n = m.Float64Abs(p0); |
1021 Stream s = m.Build(); | 1037 m.Return(n); |
1022 ASSERT_EQ(1U, s.size()); | 1038 Stream s = m.Build(); |
1023 EXPECT_EQ(kSSEFloat64Abs, s[0]->arch_opcode()); | 1039 ASSERT_EQ(1U, s.size()); |
1024 ASSERT_EQ(1U, s[0]->InputCount()); | 1040 EXPECT_EQ(kSSEFloat64Abs, s[0]->arch_opcode()); |
1025 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1041 ASSERT_EQ(1U, s[0]->InputCount()); |
1026 ASSERT_EQ(1U, s[0]->OutputCount()); | 1042 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
1027 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output())); | 1043 ASSERT_EQ(1U, s[0]->OutputCount()); |
1028 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1044 EXPECT_TRUE(s.IsSameAsFirst(s[0]->Output())); |
1029 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1045 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1046 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1047 } |
| 1048 { |
| 1049 StreamBuilder m(this, kMachFloat64, kMachFloat64); |
| 1050 Node* const p0 = m.Parameter(0); |
| 1051 Node* const n = m.Float64Abs(p0); |
| 1052 m.Return(n); |
| 1053 Stream s = m.Build(AVX); |
| 1054 ASSERT_EQ(1U, s.size()); |
| 1055 EXPECT_EQ(kAVXFloat64Abs, s[0]->arch_opcode()); |
| 1056 ASSERT_EQ(1U, s[0]->InputCount()); |
| 1057 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1058 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1059 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1060 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1061 } |
1030 } | 1062 } |
1031 | 1063 |
1032 | 1064 |
1033 TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { | 1065 TEST_F(InstructionSelectorTest, Float64BinopArithmetic) { |
1034 { | 1066 { |
1035 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); | 1067 StreamBuilder m(this, kMachFloat64, kMachFloat64, kMachFloat64); |
1036 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); | 1068 Node* add = m.Float64Add(m.Parameter(0), m.Parameter(1)); |
1037 Node* mul = m.Float64Mul(add, m.Parameter(1)); | 1069 Node* mul = m.Float64Mul(add, m.Parameter(1)); |
1038 Node* sub = m.Float64Sub(mul, add); | 1070 Node* sub = m.Float64Sub(mul, add); |
1039 Node* ret = m.Float64Div(mul, sub); | 1071 Node* ret = m.Float64Div(mul, sub); |
(...skipping 16 matching lines...) Expand all Loading... |
1056 ASSERT_EQ(4U, s.size()); | 1088 ASSERT_EQ(4U, s.size()); |
1057 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode()); | 1089 EXPECT_EQ(kSSEFloat64Add, s[0]->arch_opcode()); |
1058 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode()); | 1090 EXPECT_EQ(kSSEFloat64Mul, s[1]->arch_opcode()); |
1059 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode()); | 1091 EXPECT_EQ(kSSEFloat64Sub, s[2]->arch_opcode()); |
1060 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode()); | 1092 EXPECT_EQ(kSSEFloat64Div, s[3]->arch_opcode()); |
1061 } | 1093 } |
1062 } | 1094 } |
1063 | 1095 |
1064 | 1096 |
1065 TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) { | 1097 TEST_F(InstructionSelectorTest, Float32SubWithMinusZeroAndParameter) { |
1066 StreamBuilder m(this, kMachFloat32, kMachFloat32); | 1098 { |
1067 Node* const p0 = m.Parameter(0); | 1099 StreamBuilder m(this, kMachFloat32, kMachFloat32); |
1068 Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); | 1100 Node* const p0 = m.Parameter(0); |
1069 m.Return(n); | 1101 Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); |
1070 Stream s = m.Build(); | 1102 m.Return(n); |
1071 ASSERT_EQ(1U, s.size()); | 1103 Stream s = m.Build(); |
1072 EXPECT_EQ(kSSEFloat32Neg, s[0]->arch_opcode()); | 1104 ASSERT_EQ(1U, s.size()); |
1073 ASSERT_EQ(1U, s[0]->InputCount()); | 1105 EXPECT_EQ(kSSEFloat32Neg, s[0]->arch_opcode()); |
1074 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1106 ASSERT_EQ(1U, s[0]->InputCount()); |
1075 ASSERT_EQ(1U, s[0]->OutputCount()); | 1107 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
1076 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1108 ASSERT_EQ(1U, s[0]->OutputCount()); |
1077 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1109 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1110 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1111 } |
| 1112 { |
| 1113 StreamBuilder m(this, kMachFloat32, kMachFloat32); |
| 1114 Node* const p0 = m.Parameter(0); |
| 1115 Node* const n = m.Float32Sub(m.Float32Constant(-0.0f), p0); |
| 1116 m.Return(n); |
| 1117 Stream s = m.Build(AVX); |
| 1118 ASSERT_EQ(1U, s.size()); |
| 1119 EXPECT_EQ(kAVXFloat32Neg, s[0]->arch_opcode()); |
| 1120 ASSERT_EQ(1U, s[0]->InputCount()); |
| 1121 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1122 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1123 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1124 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1125 } |
1078 } | 1126 } |
1079 | 1127 |
1080 | 1128 |
1081 TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { | 1129 TEST_F(InstructionSelectorTest, Float64SubWithMinusZeroAndParameter) { |
1082 StreamBuilder m(this, kMachFloat64, kMachFloat64); | 1130 { |
1083 Node* const p0 = m.Parameter(0); | 1131 StreamBuilder m(this, kMachFloat64, kMachFloat64); |
1084 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); | 1132 Node* const p0 = m.Parameter(0); |
1085 m.Return(n); | 1133 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); |
1086 Stream s = m.Build(); | 1134 m.Return(n); |
1087 ASSERT_EQ(1U, s.size()); | 1135 Stream s = m.Build(); |
1088 EXPECT_EQ(kSSEFloat64Neg, s[0]->arch_opcode()); | 1136 ASSERT_EQ(1U, s.size()); |
1089 ASSERT_EQ(1U, s[0]->InputCount()); | 1137 EXPECT_EQ(kSSEFloat64Neg, s[0]->arch_opcode()); |
1090 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1138 ASSERT_EQ(1U, s[0]->InputCount()); |
1091 ASSERT_EQ(1U, s[0]->OutputCount()); | 1139 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
1092 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1140 ASSERT_EQ(1U, s[0]->OutputCount()); |
1093 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); | 1141 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1142 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1143 } |
| 1144 { |
| 1145 StreamBuilder m(this, kMachFloat64, kMachFloat64); |
| 1146 Node* const p0 = m.Parameter(0); |
| 1147 Node* const n = m.Float64Sub(m.Float64Constant(-0.0), p0); |
| 1148 m.Return(n); |
| 1149 Stream s = m.Build(AVX); |
| 1150 ASSERT_EQ(1U, s.size()); |
| 1151 EXPECT_EQ(kAVXFloat64Neg, s[0]->arch_opcode()); |
| 1152 ASSERT_EQ(1U, s[0]->InputCount()); |
| 1153 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
| 1154 ASSERT_EQ(1U, s[0]->OutputCount()); |
| 1155 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
| 1156 EXPECT_EQ(kFlags_none, s[0]->flags_mode()); |
| 1157 } |
1094 } | 1158 } |
1095 | 1159 |
1096 | 1160 |
1097 // ----------------------------------------------------------------------------- | 1161 // ----------------------------------------------------------------------------- |
1098 // Miscellaneous. | 1162 // Miscellaneous. |
1099 | 1163 |
1100 | 1164 |
1101 TEST_F(InstructionSelectorTest, Uint64LessThanWithLoadAndLoadStackPointer) { | 1165 TEST_F(InstructionSelectorTest, Uint64LessThanWithLoadAndLoadStackPointer) { |
1102 StreamBuilder m(this, kMachBool); | 1166 StreamBuilder m(this, kMachBool); |
1103 Node* const sl = m.Load( | 1167 Node* const sl = m.Load( |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1225 EXPECT_EQ(kX64Lzcnt32, s[0]->arch_opcode()); | 1289 EXPECT_EQ(kX64Lzcnt32, s[0]->arch_opcode()); |
1226 ASSERT_EQ(1U, s[0]->InputCount()); | 1290 ASSERT_EQ(1U, s[0]->InputCount()); |
1227 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); | 1291 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); |
1228 ASSERT_EQ(1U, s[0]->OutputCount()); | 1292 ASSERT_EQ(1U, s[0]->OutputCount()); |
1229 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); | 1293 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); |
1230 } | 1294 } |
1231 | 1295 |
1232 } // namespace compiler | 1296 } // namespace compiler |
1233 } // namespace internal | 1297 } // namespace internal |
1234 } // namespace v8 | 1298 } // namespace v8 |
OLD | NEW |