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

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

Issue 705983002: [turbofan][arm64] Optimize shifts combined with truncations or extensions. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/arm64/instruction-selector-arm64.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 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace compiler { 9 namespace compiler {
10 10
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1))); 1222 EXPECT_EQ(imm, s.ToInt32(s[0]->InputAt(1)));
1223 EXPECT_EQ(1U, s[0]->OutputCount()); 1223 EXPECT_EQ(1U, s[0]->OutputCount());
1224 } 1224 }
1225 } 1225 }
1226 1226
1227 1227
1228 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorShiftTest, 1228 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorShiftTest,
1229 ::testing::ValuesIn(kShiftInstructions)); 1229 ::testing::ValuesIn(kShiftInstructions));
1230 1230
1231 1231
1232 TEST_F(InstructionSelectorTest, Word64ShlWithChangeInt32ToInt64) {
1233 TRACED_FORRANGE(int64_t, x, 32, 63) {
1234 StreamBuilder m(this, kMachInt64, kMachInt32);
1235 Node* const p0 = m.Parameter(0);
1236 Node* const n = m.Word64Shl(m.ChangeInt32ToInt64(p0), m.Int64Constant(x));
1237 m.Return(n);
1238 Stream s = m.Build();
1239 ASSERT_EQ(1U, s.size());
1240 EXPECT_EQ(kArm64Lsl, s[0]->arch_opcode());
1241 ASSERT_EQ(2U, s[0]->InputCount());
1242 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1243 EXPECT_EQ(x, s.ToInt64(s[0]->InputAt(1)));
1244 ASSERT_EQ(1U, s[0]->OutputCount());
1245 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1246 }
1247 }
1248
1249
1250 TEST_F(InstructionSelectorTest, Word64ShlWithChangeUint32ToUint64) {
1251 TRACED_FORRANGE(int64_t, x, 32, 63) {
1252 StreamBuilder m(this, kMachInt64, kMachUint32);
1253 Node* const p0 = m.Parameter(0);
1254 Node* const n = m.Word64Shl(m.ChangeUint32ToUint64(p0), m.Int64Constant(x));
1255 m.Return(n);
1256 Stream s = m.Build();
1257 ASSERT_EQ(1U, s.size());
1258 EXPECT_EQ(kArm64Lsl, s[0]->arch_opcode());
1259 ASSERT_EQ(2U, s[0]->InputCount());
1260 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1261 EXPECT_EQ(x, s.ToInt64(s[0]->InputAt(1)));
1262 ASSERT_EQ(1U, s[0]->OutputCount());
1263 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1264 }
1265 }
1266
1267
1268 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Sar) {
1269 StreamBuilder m(this, kMachInt32, kMachInt64);
1270 Node* const p = m.Parameter(0);
1271 Node* const t = m.TruncateInt64ToInt32(m.Word64Sar(p, m.Int64Constant(32)));
1272 m.Return(t);
1273 Stream s = m.Build();
1274 ASSERT_EQ(1U, s.size());
1275 EXPECT_EQ(kArm64Lsr, s[0]->arch_opcode());
1276 ASSERT_EQ(2U, s[0]->InputCount());
1277 EXPECT_EQ(s.ToVreg(p), s.ToVreg(s[0]->InputAt(0)));
1278 EXPECT_EQ(32, s.ToInt64(s[0]->InputAt(1)));
1279 ASSERT_EQ(1U, s[0]->OutputCount());
1280 EXPECT_EQ(s.ToVreg(t), s.ToVreg(s[0]->OutputAt(0)));
1281 }
1282
1283
1284 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Shr) {
1285 TRACED_FORRANGE(int64_t, x, 32, 63) {
1286 StreamBuilder m(this, kMachInt32, kMachInt64);
1287 Node* const p = m.Parameter(0);
1288 Node* const t = m.TruncateInt64ToInt32(m.Word64Shr(p, m.Int64Constant(x)));
1289 m.Return(t);
1290 Stream s = m.Build();
1291 ASSERT_EQ(1U, s.size());
1292 EXPECT_EQ(kArm64Lsr, s[0]->arch_opcode());
1293 ASSERT_EQ(2U, s[0]->InputCount());
1294 EXPECT_EQ(s.ToVreg(p), s.ToVreg(s[0]->InputAt(0)));
1295 EXPECT_EQ(x, s.ToInt64(s[0]->InputAt(1)));
1296 ASSERT_EQ(1U, s[0]->OutputCount());
1297 EXPECT_EQ(s.ToVreg(t), s.ToVreg(s[0]->OutputAt(0)));
1298 }
1299 }
1300
1301
1232 // ----------------------------------------------------------------------------- 1302 // -----------------------------------------------------------------------------
1233 // Mul and Div instructions. 1303 // Mul and Div instructions.
1234 1304
1235 1305
1236 typedef InstructionSelectorTestWithParam<MachInst2> 1306 typedef InstructionSelectorTestWithParam<MachInst2>
1237 InstructionSelectorMulDivTest; 1307 InstructionSelectorMulDivTest;
1238 1308
1239 1309
1240 TEST_P(InstructionSelectorMulDivTest, Parameter) { 1310 TEST_P(InstructionSelectorMulDivTest, Parameter) {
1241 const MachInst2 dpi = GetParam(); 1311 const MachInst2 dpi = GetParam();
(...skipping 778 matching lines...) Expand 10 before | Expand all | Expand 10 after
2020 ASSERT_EQ(2U, s[1]->InputCount()); 2090 ASSERT_EQ(2U, s[1]->InputCount());
2021 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0))); 2091 EXPECT_EQ(s.ToVreg(s[0]->Output()), s.ToVreg(s[1]->InputAt(0)));
2022 EXPECT_EQ(32, s.ToInt64(s[1]->InputAt(1))); 2092 EXPECT_EQ(32, s.ToInt64(s[1]->InputAt(1)));
2023 ASSERT_EQ(1U, s[1]->OutputCount()); 2093 ASSERT_EQ(1U, s[1]->OutputCount());
2024 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[1]->Output())); 2094 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[1]->Output()));
2025 } 2095 }
2026 2096
2027 } // namespace compiler 2097 } // namespace compiler
2028 } // namespace internal 2098 } // namespace internal
2029 } // namespace v8 2099 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/arm64/instruction-selector-arm64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698