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

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

Issue 1056543002: [turbofan][arm64] Match add with shifted operand for mult by a power of 2 plus 1. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 8 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/utils.h ('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 1502 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 EXPECT_EQ(1U, s[0]->OutputCount()); 1513 EXPECT_EQ(1U, s[0]->OutputCount());
1514 } 1514 }
1515 } 1515 }
1516 1516
1517 1517
1518 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, 1518 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
1519 InstructionSelectorIntDPWithIntMulTest, 1519 InstructionSelectorIntDPWithIntMulTest,
1520 ::testing::ValuesIn(kMulDPInstructions)); 1520 ::testing::ValuesIn(kMulDPInstructions));
1521 1521
1522 1522
1523 TEST_F(InstructionSelectorTest, Int32MulWithImmediate) {
1524 // x * (2^k + 1) -> x + (x << k)
1525 TRACED_FORRANGE(int32_t, k, 1, 30) {
1526 StreamBuilder m(this, kMachInt32, kMachInt32);
1527 m.Return(m.Int32Mul(m.Parameter(0), m.Int32Constant((1 << k) + 1)));
1528 Stream s = m.Build();
1529 ASSERT_EQ(1U, s.size());
1530 EXPECT_EQ(kArm64Add32, s[0]->arch_opcode());
1531 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
1532 ASSERT_EQ(3U, s[0]->InputCount());
1533 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1)));
1534 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2)));
1535 EXPECT_EQ(1U, s[0]->OutputCount());
1536 }
1537 // (2^k + 1) * x -> x + (x << k)
1538 TRACED_FORRANGE(int32_t, k, 1, 30) {
1539 StreamBuilder m(this, kMachInt32, kMachInt32);
1540 m.Return(m.Int32Mul(m.Int32Constant((1 << k) + 1), m.Parameter(0)));
1541 Stream s = m.Build();
1542 ASSERT_EQ(1U, s.size());
1543 EXPECT_EQ(kArm64Add32, s[0]->arch_opcode());
1544 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
1545 ASSERT_EQ(3U, s[0]->InputCount());
1546 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1)));
1547 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(2)));
1548 EXPECT_EQ(1U, s[0]->OutputCount());
1549 }
1550 }
1551
1552
1553 TEST_F(InstructionSelectorTest, Int64MulWithImmediate) {
1554 // x * (2^k + 1) -> x + (x << k)
1555 TRACED_FORRANGE(int64_t, k, 1, 62) {
1556 StreamBuilder m(this, kMachInt64, kMachInt64);
1557 m.Return(m.Int64Mul(m.Parameter(0), m.Int64Constant((1L << k) + 1)));
1558 Stream s = m.Build();
1559 ASSERT_EQ(1U, s.size());
1560 EXPECT_EQ(kArm64Add, s[0]->arch_opcode());
1561 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
1562 ASSERT_EQ(3U, s[0]->InputCount());
1563 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1)));
1564 EXPECT_EQ(k, s.ToInt64(s[0]->InputAt(2)));
1565 EXPECT_EQ(1U, s[0]->OutputCount());
1566 }
1567 // (2^k + 1) * x -> x + (x << k)
1568 TRACED_FORRANGE(int64_t, k, 1, 62) {
1569 StreamBuilder m(this, kMachInt64, kMachInt64);
1570 m.Return(m.Int64Mul(m.Int64Constant((1L << k) + 1), m.Parameter(0)));
1571 Stream s = m.Build();
1572 ASSERT_EQ(1U, s.size());
1573 EXPECT_EQ(kArm64Add, s[0]->arch_opcode());
1574 EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
1575 ASSERT_EQ(3U, s[0]->InputCount());
1576 EXPECT_EQ(s.ToVreg(s[0]->InputAt(0)), s.ToVreg(s[0]->InputAt(1)));
1577 EXPECT_EQ(k, s.ToInt64(s[0]->InputAt(2)));
1578 EXPECT_EQ(1U, s[0]->OutputCount());
1579 }
1580 }
1581
1582
1523 // ----------------------------------------------------------------------------- 1583 // -----------------------------------------------------------------------------
1524 // Floating point instructions. 1584 // Floating point instructions.
1525 1585
1526 typedef InstructionSelectorTestWithParam<MachInst2> 1586 typedef InstructionSelectorTestWithParam<MachInst2>
1527 InstructionSelectorFPArithTest; 1587 InstructionSelectorFPArithTest;
1528 1588
1529 1589
1530 TEST_P(InstructionSelectorFPArithTest, Parameter) { 1590 TEST_P(InstructionSelectorFPArithTest, Parameter) {
1531 const MachInst2 fpa = GetParam(); 1591 const MachInst2 fpa = GetParam();
1532 StreamBuilder m(this, fpa.machine_type, fpa.machine_type, fpa.machine_type); 1592 StreamBuilder m(this, fpa.machine_type, fpa.machine_type, fpa.machine_type);
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
2268 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode()); 2328 EXPECT_EQ(kArm64Float64Neg, s[0]->arch_opcode());
2269 ASSERT_EQ(1U, s[0]->InputCount()); 2329 ASSERT_EQ(1U, s[0]->InputCount());
2270 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 2330 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2271 ASSERT_EQ(1U, s[0]->OutputCount()); 2331 ASSERT_EQ(1U, s[0]->OutputCount());
2272 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 2332 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
2273 } 2333 }
2274 2334
2275 } // namespace compiler 2335 } // namespace compiler
2276 } // namespace internal 2336 } // namespace internal
2277 } // namespace v8 2337 } // namespace v8
OLDNEW
« no previous file with comments | « src/utils.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698