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

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

Issue 709123005: [arm] Recognize SXTB, SXTH, UXTB and UXTH. (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 | « test/mjsunit/asm/zero-extend.js ('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 <limits> 5 #include <limits>
6 6
7 #include "test/unittests/compiler/instruction-selector-unittest.h" 7 #include "test/unittests/compiler/instruction-selector-unittest.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1551 ASSERT_EQ(3U, s[0]->InputCount()); 1551 ASSERT_EQ(3U, s[0]->InputCount());
1552 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0))); 1552 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0)));
1553 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(1))); 1553 EXPECT_EQ(s.ToVreg(p2), s.ToVreg(s[0]->InputAt(1)));
1554 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(2))); 1554 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(2)));
1555 ASSERT_EQ(1U, s[0]->OutputCount()); 1555 ASSERT_EQ(1U, s[0]->OutputCount());
1556 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 1556 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1557 } 1557 }
1558 } 1558 }
1559 1559
1560 1560
1561 TEST_F(InstructionSelectorTest, Int32AddWithWord32And) {
1562 {
1563 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1564 Node* const p0 = m.Parameter(0);
1565 Node* const p1 = m.Parameter(1);
1566 Node* const r = m.Int32Add(m.Word32And(p0, m.Int32Constant(0xff)), p1);
1567 m.Return(r);
1568 Stream s = m.Build();
1569 ASSERT_EQ(1U, s.size());
1570 EXPECT_EQ(kArmUxtab, s[0]->arch_opcode());
1571 ASSERT_EQ(3U, s[0]->InputCount());
1572 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0)));
1573 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
1574 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2)));
1575 ASSERT_EQ(1U, s[0]->OutputCount());
1576 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
1577 }
1578 {
1579 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1580 Node* const p0 = m.Parameter(0);
1581 Node* const p1 = m.Parameter(1);
1582 Node* const r = m.Int32Add(p1, m.Word32And(p0, m.Int32Constant(0xff)));
1583 m.Return(r);
1584 Stream s = m.Build();
1585 ASSERT_EQ(1U, s.size());
1586 EXPECT_EQ(kArmUxtab, s[0]->arch_opcode());
1587 ASSERT_EQ(3U, s[0]->InputCount());
1588 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0)));
1589 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
1590 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2)));
1591 ASSERT_EQ(1U, s[0]->OutputCount());
1592 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
1593 }
1594 {
1595 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1596 Node* const p0 = m.Parameter(0);
1597 Node* const p1 = m.Parameter(1);
1598 Node* const r = m.Int32Add(m.Word32And(p0, m.Int32Constant(0xffff)), p1);
1599 m.Return(r);
1600 Stream s = m.Build();
1601 ASSERT_EQ(1U, s.size());
1602 EXPECT_EQ(kArmUxtah, s[0]->arch_opcode());
1603 ASSERT_EQ(3U, s[0]->InputCount());
1604 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0)));
1605 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
1606 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2)));
1607 ASSERT_EQ(1U, s[0]->OutputCount());
1608 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
1609 }
1610 {
1611 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1612 Node* const p0 = m.Parameter(0);
1613 Node* const p1 = m.Parameter(1);
1614 Node* const r = m.Int32Add(p1, m.Word32And(p0, m.Int32Constant(0xffff)));
1615 m.Return(r);
1616 Stream s = m.Build();
1617 ASSERT_EQ(1U, s.size());
1618 EXPECT_EQ(kArmUxtah, s[0]->arch_opcode());
1619 ASSERT_EQ(3U, s[0]->InputCount());
1620 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0)));
1621 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
1622 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2)));
1623 ASSERT_EQ(1U, s[0]->OutputCount());
1624 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
1625 }
1626 }
1627
1628
1629 TEST_F(InstructionSelectorTest, Int32AddWithWord32SarWithWord32Shl) {
1630 {
1631 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1632 Node* const p0 = m.Parameter(0);
1633 Node* const p1 = m.Parameter(1);
1634 Node* const r = m.Int32Add(
1635 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(24)), m.Int32Constant(24)),
1636 p1);
1637 m.Return(r);
1638 Stream s = m.Build();
1639 ASSERT_EQ(1U, s.size());
1640 EXPECT_EQ(kArmSxtab, s[0]->arch_opcode());
1641 ASSERT_EQ(3U, s[0]->InputCount());
1642 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0)));
1643 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
1644 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2)));
1645 ASSERT_EQ(1U, s[0]->OutputCount());
1646 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
1647 }
1648 {
1649 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1650 Node* const p0 = m.Parameter(0);
1651 Node* const p1 = m.Parameter(1);
1652 Node* const r = m.Int32Add(
1653 p1,
1654 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(24)), m.Int32Constant(24)));
1655 m.Return(r);
1656 Stream s = m.Build();
1657 ASSERT_EQ(1U, s.size());
1658 EXPECT_EQ(kArmSxtab, s[0]->arch_opcode());
1659 ASSERT_EQ(3U, s[0]->InputCount());
1660 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0)));
1661 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
1662 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2)));
1663 ASSERT_EQ(1U, s[0]->OutputCount());
1664 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
1665 }
1666 {
1667 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1668 Node* const p0 = m.Parameter(0);
1669 Node* const p1 = m.Parameter(1);
1670 Node* const r = m.Int32Add(
1671 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(16)), m.Int32Constant(16)),
1672 p1);
1673 m.Return(r);
1674 Stream s = m.Build();
1675 ASSERT_EQ(1U, s.size());
1676 EXPECT_EQ(kArmSxtah, s[0]->arch_opcode());
1677 ASSERT_EQ(3U, s[0]->InputCount());
1678 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0)));
1679 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
1680 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2)));
1681 ASSERT_EQ(1U, s[0]->OutputCount());
1682 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
1683 }
1684 {
1685 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
1686 Node* const p0 = m.Parameter(0);
1687 Node* const p1 = m.Parameter(1);
1688 Node* const r = m.Int32Add(
1689 p1,
1690 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(16)), m.Int32Constant(16)));
1691 m.Return(r);
1692 Stream s = m.Build();
1693 ASSERT_EQ(1U, s.size());
1694 EXPECT_EQ(kArmSxtah, s[0]->arch_opcode());
1695 ASSERT_EQ(3U, s[0]->InputCount());
1696 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(0)));
1697 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(1)));
1698 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(2)));
1699 ASSERT_EQ(1U, s[0]->OutputCount());
1700 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
1701 }
1702 }
1703
1704
1561 TEST_F(InstructionSelectorTest, Int32SubWithInt32Mul) { 1705 TEST_F(InstructionSelectorTest, Int32SubWithInt32Mul) {
1562 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32); 1706 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32, kMachInt32);
1563 m.Return( 1707 m.Return(
1564 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2)))); 1708 m.Int32Sub(m.Parameter(0), m.Int32Mul(m.Parameter(1), m.Parameter(2))));
1565 Stream s = m.Build(); 1709 Stream s = m.Build();
1566 ASSERT_EQ(2U, s.size()); 1710 ASSERT_EQ(2U, s.size());
1567 EXPECT_EQ(kArmMul, s[0]->arch_opcode()); 1711 EXPECT_EQ(kArmMul, s[0]->arch_opcode());
1568 ASSERT_EQ(1U, s[0]->OutputCount()); 1712 ASSERT_EQ(1U, s[0]->OutputCount());
1569 EXPECT_EQ(kArmSub, s[1]->arch_opcode()); 1713 EXPECT_EQ(kArmSub, s[1]->arch_opcode());
1570 ASSERT_EQ(2U, s[1]->InputCount()); 1714 ASSERT_EQ(2U, s[1]->InputCount());
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
1936 EXPECT_TRUE( 2080 EXPECT_TRUE(
1937 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy()); 2081 UnallocatedOperand::cast(s[0]->Output())->HasSameAsInputPolicy());
1938 ASSERT_EQ(3U, s[0]->InputCount()); 2082 ASSERT_EQ(3U, s[0]->InputCount());
1939 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); 2083 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1)));
1940 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); 2084 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2)));
1941 } 2085 }
1942 } 2086 }
1943 } 2087 }
1944 2088
1945 2089
2090 TEST_F(InstructionSelectorTest, Word32AndWith0xffff) {
2091 {
2092 StreamBuilder m(this, kMachInt32, kMachInt32);
2093 Node* const p0 = m.Parameter(0);
2094 Node* const r = m.Word32And(p0, m.Int32Constant(0xffff));
2095 m.Return(r);
2096 Stream s = m.Build();
2097 ASSERT_EQ(1U, s.size());
2098 EXPECT_EQ(kArmUxth, s[0]->arch_opcode());
2099 ASSERT_EQ(2U, s[0]->InputCount());
2100 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2101 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1)));
2102 ASSERT_EQ(1U, s[0]->OutputCount());
2103 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
2104 }
2105 {
2106 StreamBuilder m(this, kMachInt32, kMachInt32);
2107 Node* const p0 = m.Parameter(0);
2108 Node* const r = m.Word32And(m.Int32Constant(0xffff), p0);
2109 m.Return(r);
2110 Stream s = m.Build();
2111 ASSERT_EQ(1U, s.size());
2112 EXPECT_EQ(kArmUxth, s[0]->arch_opcode());
2113 ASSERT_EQ(2U, s[0]->InputCount());
2114 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2115 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1)));
2116 ASSERT_EQ(1U, s[0]->OutputCount());
2117 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
2118 }
2119 }
2120
2121
2122 TEST_F(InstructionSelectorTest, Word32SarWithWord32Shl) {
2123 {
2124 StreamBuilder m(this, kMachInt32, kMachInt32);
2125 Node* const p0 = m.Parameter(0);
2126 Node* const r =
2127 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(24)), m.Int32Constant(24));
2128 m.Return(r);
2129 Stream s = m.Build();
2130 ASSERT_EQ(1U, s.size());
2131 EXPECT_EQ(kArmSxtb, s[0]->arch_opcode());
2132 ASSERT_EQ(2U, s[0]->InputCount());
2133 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2134 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1)));
2135 ASSERT_EQ(1U, s[0]->OutputCount());
2136 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
2137 }
2138 {
2139 StreamBuilder m(this, kMachInt32, kMachInt32);
2140 Node* const p0 = m.Parameter(0);
2141 Node* const r =
2142 m.Word32Sar(m.Word32Shl(p0, m.Int32Constant(16)), m.Int32Constant(16));
2143 m.Return(r);
2144 Stream s = m.Build();
2145 ASSERT_EQ(1U, s.size());
2146 EXPECT_EQ(kArmSxth, s[0]->arch_opcode());
2147 ASSERT_EQ(2U, s[0]->InputCount());
2148 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
2149 EXPECT_EQ(0, s.ToInt32(s[0]->InputAt(1)));
2150 ASSERT_EQ(1U, s[0]->OutputCount());
2151 EXPECT_EQ(s.ToVreg(r), s.ToVreg(s[0]->Output()));
2152 }
2153 }
2154
2155
1946 TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediateForARMv7) { 2156 TEST_F(InstructionSelectorTest, Word32ShrWithWord32AndWithImmediateForARMv7) {
1947 TRACED_FORRANGE(int32_t, lsb, 0, 31) { 2157 TRACED_FORRANGE(int32_t, lsb, 0, 31) {
1948 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) { 2158 TRACED_FORRANGE(int32_t, width, 1, 32 - lsb) {
1949 uint32_t max = 1 << lsb; 2159 uint32_t max = 1 << lsb;
1950 if (max > static_cast<uint32_t>(kMaxInt)) max -= 1; 2160 if (max > static_cast<uint32_t>(kMaxInt)) max -= 1;
1951 uint32_t jnk = rng()->NextInt(max); 2161 uint32_t jnk = rng()->NextInt(max);
1952 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk; 2162 uint32_t msk = ((0xffffffffu >> (32 - width)) << lsb) | jnk;
1953 StreamBuilder m(this, kMachInt32, kMachInt32); 2163 StreamBuilder m(this, kMachInt32, kMachInt32);
1954 m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)), 2164 m.Return(m.Word32Shr(m.Word32And(m.Parameter(0), m.Int32Constant(msk)),
1955 m.Int32Constant(lsb))); 2165 m.Int32Constant(lsb)));
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2118 ASSERT_EQ(3U, s[0]->InputCount()); 2328 ASSERT_EQ(3U, s[0]->InputCount());
2119 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1))); 2329 EXPECT_EQ(lsb, s.ToInt32(s[0]->InputAt(1)));
2120 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2))); 2330 EXPECT_EQ(width, s.ToInt32(s[0]->InputAt(2)));
2121 } 2331 }
2122 } 2332 }
2123 } 2333 }
2124 2334
2125 } // namespace compiler 2335 } // namespace compiler
2126 } // namespace internal 2336 } // namespace internal
2127 } // namespace v8 2337 } // namespace v8
OLDNEW
« no previous file with comments | « test/mjsunit/asm/zero-extend.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698