OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 "src/assembler-inl.h" | 5 #include "src/assembler-inl.h" |
6 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 #include "test/cctest/compiler/value-helper.h" | 7 #include "test/cctest/compiler/value-helper.h" |
8 #include "test/cctest/wasm/wasm-run-utils.h" | 8 #include "test/cctest/wasm/wasm-run-utils.h" |
9 #include "test/common/wasm/wasm-macro-gen.h" | 9 #include "test/common/wasm/wasm-macro-gen.h" |
10 | 10 |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 x, WASM_SIMD_OP(kExprI16x8ExtractLane), TO_BYTE(lane) | 392 x, WASM_SIMD_OP(kExprI16x8ExtractLane), TO_BYTE(lane) |
393 #define WASM_SIMD_I16x8_REPLACE_LANE(lane, x, y) \ | 393 #define WASM_SIMD_I16x8_REPLACE_LANE(lane, x, y) \ |
394 x, y, WASM_SIMD_OP(kExprI16x8ReplaceLane), TO_BYTE(lane) | 394 x, y, WASM_SIMD_OP(kExprI16x8ReplaceLane), TO_BYTE(lane) |
395 | 395 |
396 #define WASM_SIMD_I8x16_SPLAT(x) x, WASM_SIMD_OP(kExprI8x16Splat) | 396 #define WASM_SIMD_I8x16_SPLAT(x) x, WASM_SIMD_OP(kExprI8x16Splat) |
397 #define WASM_SIMD_I8x16_EXTRACT_LANE(lane, x) \ | 397 #define WASM_SIMD_I8x16_EXTRACT_LANE(lane, x) \ |
398 x, WASM_SIMD_OP(kExprI8x16ExtractLane), TO_BYTE(lane) | 398 x, WASM_SIMD_OP(kExprI8x16ExtractLane), TO_BYTE(lane) |
399 #define WASM_SIMD_I8x16_REPLACE_LANE(lane, x, y) \ | 399 #define WASM_SIMD_I8x16_REPLACE_LANE(lane, x, y) \ |
400 x, y, WASM_SIMD_OP(kExprI8x16ReplaceLane), TO_BYTE(lane) | 400 x, y, WASM_SIMD_OP(kExprI8x16ReplaceLane), TO_BYTE(lane) |
401 | 401 |
402 #define WASM_SIMD_S32x4_SHUFFLE_OP(opcode, m, x, y) \ | |
403 x, y, WASM_SIMD_OP(opcode), TO_BYTE(m[0]), TO_BYTE(m[1]), TO_BYTE(m[2]), \ | |
404 TO_BYTE(m[3]) | |
405 #define WASM_SIMD_S16x8_SHUFFLE_OP(opcode, m, x, y) \ | |
406 x, y, WASM_SIMD_OP(opcode), TO_BYTE(m[0]), TO_BYTE(m[1]), TO_BYTE(m[2]), \ | |
407 TO_BYTE(m[3]), TO_BYTE(m[4]), TO_BYTE(m[5]), TO_BYTE(m[6]), \ | |
408 TO_BYTE(m[7]) | |
409 #define WASM_SIMD_S8x16_SHUFFLE_OP(opcode, m, x, y) \ | 402 #define WASM_SIMD_S8x16_SHUFFLE_OP(opcode, m, x, y) \ |
410 x, y, WASM_SIMD_OP(opcode), TO_BYTE(m[0]), TO_BYTE(m[1]), TO_BYTE(m[2]), \ | 403 x, y, WASM_SIMD_OP(opcode), TO_BYTE(m[0]), TO_BYTE(m[1]), TO_BYTE(m[2]), \ |
411 TO_BYTE(m[3]), TO_BYTE(m[4]), TO_BYTE(m[5]), TO_BYTE(m[6]), \ | 404 TO_BYTE(m[3]), TO_BYTE(m[4]), TO_BYTE(m[5]), TO_BYTE(m[6]), \ |
412 TO_BYTE(m[7]), TO_BYTE(m[8]), TO_BYTE(m[9]), TO_BYTE(m[10]), \ | 405 TO_BYTE(m[7]), TO_BYTE(m[8]), TO_BYTE(m[9]), TO_BYTE(m[10]), \ |
413 TO_BYTE(m[11]), TO_BYTE(m[12]), TO_BYTE(m[13]), TO_BYTE(m[14]), \ | 406 TO_BYTE(m[11]), TO_BYTE(m[12]), TO_BYTE(m[13]), TO_BYTE(m[14]), \ |
414 TO_BYTE(m[15]) | 407 TO_BYTE(m[15]) |
415 | 408 |
416 // Skip FP tests involving extremely large or extremely small values, which | 409 // Skip FP tests involving extremely large or extremely small values, which |
417 // may fail due to non-IEEE-754 SIMD arithmetic on some platforms. | 410 // may fail due to non-IEEE-754 SIMD arithmetic on some platforms. |
418 bool SkipFPValue(float x) { | 411 bool SkipFPValue(float x) { |
(...skipping 1162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1581 const std::array<T, kSimd128Size / sizeof(T)>& expected) { | 1574 const std::array<T, kSimd128Size / sizeof(T)>& expected) { |
1582 WasmRunner<int32_t> r(kExecuteCompiled); | 1575 WasmRunner<int32_t> r(kExecuteCompiled); |
1583 // Set up two test patterns as globals, e.g. [0, 1, 2, 3] and [4, 5, 6, 7]. | 1576 // Set up two test patterns as globals, e.g. [0, 1, 2, 3] and [4, 5, 6, 7]. |
1584 T* src0 = r.module().AddGlobal<T>(kWasmS128); | 1577 T* src0 = r.module().AddGlobal<T>(kWasmS128); |
1585 T* src1 = r.module().AddGlobal<T>(kWasmS128); | 1578 T* src1 = r.module().AddGlobal<T>(kWasmS128); |
1586 static const int kElems = kSimd128Size / sizeof(T); | 1579 static const int kElems = kSimd128Size / sizeof(T); |
1587 for (int i = 0; i < kElems; i++) { | 1580 for (int i = 0; i < kElems; i++) { |
1588 src0[i] = i; | 1581 src0[i] = i; |
1589 src1[i] = kElems + i; | 1582 src1[i] = kElems + i; |
1590 } | 1583 } |
1591 switch (simd_op) { | 1584 if (simd_op == kExprS8x16Shuffle) { |
1592 case kExprS32x4Shuffle: { | 1585 BUILD(r, |
1593 BUILD(r, | 1586 WASM_SET_GLOBAL(0, WASM_SIMD_S8x16_SHUFFLE_OP(simd_op, expected, |
1594 WASM_SET_GLOBAL(0, WASM_SIMD_S32x4_SHUFFLE_OP(simd_op, expected, | 1587 WASM_GET_GLOBAL(0), |
1595 WASM_GET_GLOBAL(0), | 1588 WASM_GET_GLOBAL(1))), |
1596 WASM_GET_GLOBAL(1))), | 1589 WASM_ONE); |
1597 WASM_ONE); | 1590 } else { |
1598 break; | 1591 BUILD(r, |
1599 } | 1592 WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(simd_op, WASM_GET_GLOBAL(0), |
1600 case kExprS16x8Shuffle: { | 1593 WASM_GET_GLOBAL(1))), |
1601 BUILD(r, | 1594 WASM_ONE); |
1602 WASM_SET_GLOBAL(0, WASM_SIMD_S16x8_SHUFFLE_OP(simd_op, expected, | |
1603 WASM_GET_GLOBAL(0), | |
1604 WASM_GET_GLOBAL(1))), | |
1605 WASM_ONE); | |
1606 break; | |
1607 } | |
1608 case kExprS8x16Shuffle: { | |
1609 BUILD(r, | |
1610 WASM_SET_GLOBAL(0, WASM_SIMD_S8x16_SHUFFLE_OP(simd_op, expected, | |
1611 WASM_GET_GLOBAL(0), | |
1612 WASM_GET_GLOBAL(1))), | |
1613 WASM_ONE); | |
1614 break; | |
1615 } | |
1616 default: { | |
1617 BUILD(r, | |
1618 WASM_SET_GLOBAL(0, WASM_SIMD_BINOP(simd_op, WASM_GET_GLOBAL(0), | |
1619 WASM_GET_GLOBAL(1))), | |
1620 WASM_ONE); | |
1621 break; | |
1622 } | |
1623 } | 1595 } |
1624 | 1596 |
1625 CHECK_EQ(1, r.Call()); | 1597 CHECK_EQ(1, r.Call()); |
1626 for (size_t i = 0; i < expected.size(); i++) { | 1598 for (size_t i = 0; i < expected.size(); i++) { |
1627 CHECK_EQ(src0[i], expected[i]); | 1599 CHECK_EQ(src0[i], expected[i]); |
1628 } | 1600 } |
1629 } | 1601 } |
1630 | 1602 |
1631 WASM_SIMD_TEST(I32x4AddHoriz) { | 1603 WASM_SIMD_TEST(I32x4AddHoriz) { |
1632 RunBinaryLaneOpTest<int32_t>(kExprI32x4AddHoriz, {{1, 5, 9, 13}}); | 1604 RunBinaryLaneOpTest<int32_t>(kExprI32x4AddHoriz, {{1, 5, 9, 13}}); |
1633 } | 1605 } |
1634 | 1606 |
1635 WASM_SIMD_TEST(I16x8AddHoriz) { | 1607 WASM_SIMD_TEST(I16x8AddHoriz) { |
1636 RunBinaryLaneOpTest<int16_t>(kExprI16x8AddHoriz, | 1608 RunBinaryLaneOpTest<int16_t>(kExprI16x8AddHoriz, |
1637 {{1, 5, 9, 13, 17, 21, 25, 29}}); | 1609 {{1, 5, 9, 13, 17, 21, 25, 29}}); |
1638 } | 1610 } |
1639 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 | 1611 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 |
1640 | 1612 |
1641 #if V8_TARGET_ARCH_ARM | 1613 #if V8_TARGET_ARCH_ARM |
1642 WASM_SIMD_TEST(F32x4AddHoriz) { | 1614 WASM_SIMD_TEST(F32x4AddHoriz) { |
1643 RunBinaryLaneOpTest<float>(kExprF32x4AddHoriz, {{1.0f, 5.0f, 9.0f, 13.0f}}); | 1615 RunBinaryLaneOpTest<float>(kExprF32x4AddHoriz, {{1.0f, 5.0f, 9.0f, 13.0f}}); |
1644 } | 1616 } |
1645 | 1617 |
1646 // Test some regular shuffles that may have special handling on some targets. | 1618 // Test some regular shuffles that may have special handling on some targets. |
1647 // Test a normal and unary versions (where second operand isn't used). | 1619 // Test a normal and unary versions (where second operand isn't used). |
1648 WASM_SIMD_TEST(S32x4ZipLeft) { | 1620 WASM_SIMD_TEST(S32x4ZipLeft) { |
1649 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 4, 1, 5}}); | 1621 RunBinaryLaneOpTest<int8_t>( |
1650 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 0, 1, 1}}); | 1622 kExprS8x16Shuffle, |
| 1623 {{0, 1, 2, 3, 16, 17, 18, 19, 4, 5, 6, 7, 20, 21, 22, 23}}); |
| 1624 RunBinaryLaneOpTest<int8_t>( |
| 1625 kExprS8x16Shuffle, {{0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7}}); |
1651 } | 1626 } |
1652 | 1627 |
1653 WASM_SIMD_TEST(S32x4ZipRight) { | 1628 WASM_SIMD_TEST(S32x4ZipRight) { |
1654 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{2, 6, 3, 7}}); | 1629 RunBinaryLaneOpTest<int8_t>( |
1655 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{2, 2, 3, 3}}); | 1630 kExprS8x16Shuffle, |
| 1631 {{8, 9, 10, 11, 24, 25, 26, 27, 12, 13, 14, 15, 28, 29, 30, 31}}); |
| 1632 RunBinaryLaneOpTest<int8_t>( |
| 1633 kExprS8x16Shuffle, |
| 1634 {{8, 9, 10, 11, 8, 9, 10, 11, 12, 13, 14, 15, 12, 13, 14, 15}}); |
1656 } | 1635 } |
1657 | 1636 |
1658 WASM_SIMD_TEST(S32x4UnzipLeft) { | 1637 WASM_SIMD_TEST(S32x4UnzipLeft) { |
1659 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 2, 4, 6}}); | 1638 RunBinaryLaneOpTest<int8_t>( |
1660 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 2, 0, 2}}); | 1639 kExprS8x16Shuffle, |
| 1640 {{0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27}}); |
| 1641 RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{0, 1, 2, 3, 8, 9, 10, 11, 0, |
| 1642 1, 2, 3, 8, 9, 10, 11}}); |
1661 } | 1643 } |
1662 | 1644 |
1663 WASM_SIMD_TEST(S32x4UnzipRight) { | 1645 WASM_SIMD_TEST(S32x4UnzipRight) { |
1664 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 3, 5, 7}}); | 1646 RunBinaryLaneOpTest<int8_t>( |
1665 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 3, 1, 3}}); | 1647 kExprS8x16Shuffle, |
| 1648 {{4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31}}); |
| 1649 RunBinaryLaneOpTest<int8_t>( |
| 1650 kExprS8x16Shuffle, |
| 1651 {{4, 5, 6, 7, 12, 13, 14, 15, 4, 5, 6, 7, 12, 13, 14, 15}}); |
1666 } | 1652 } |
1667 | 1653 |
1668 WASM_SIMD_TEST(S32x4TransposeLeft) { | 1654 WASM_SIMD_TEST(S32x4TransposeLeft) { |
1669 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 4, 2, 6}}); | 1655 RunBinaryLaneOpTest<int8_t>( |
1670 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 0, 2, 2}}); | 1656 kExprS8x16Shuffle, |
| 1657 {{0, 1, 2, 3, 16, 17, 18, 19, 8, 9, 10, 11, 24, 25, 26, 27}}); |
| 1658 RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{0, 1, 2, 3, 0, 1, 2, 3, 8, 9, |
| 1659 10, 11, 8, 9, 10, 11}}); |
1671 } | 1660 } |
1672 | 1661 |
1673 WASM_SIMD_TEST(S32x4TransposeRight) { | 1662 WASM_SIMD_TEST(S32x4TransposeRight) { |
1674 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 5, 3, 7}}); | 1663 RunBinaryLaneOpTest<int8_t>( |
1675 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 1, 3, 3}}); | 1664 kExprS8x16Shuffle, |
| 1665 {{4, 5, 6, 7, 20, 21, 22, 23, 12, 13, 14, 15, 28, 29, 30, 31}}); |
| 1666 RunBinaryLaneOpTest<int8_t>( |
| 1667 kExprS8x16Shuffle, |
| 1668 {{4, 5, 6, 7, 4, 5, 6, 7, 12, 13, 14, 15, 12, 13, 14, 15}}); |
1676 } | 1669 } |
1677 | 1670 |
1678 // Reverses are only unary. | 1671 // Reverses are only unary. |
1679 WASM_SIMD_TEST(S32x2Reverse) { | 1672 WASM_SIMD_TEST(S32x2Reverse) { |
1680 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{1, 0, 3, 2}}); | 1673 RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{4, 5, 6, 7, 0, 1, 2, 3, 12, |
| 1674 13, 14, 15, 8, 9, 10, 11}}); |
1681 } | 1675 } |
1682 | 1676 |
1683 // Test irregular shuffle. | 1677 // Test irregular shuffle. |
1684 WASM_SIMD_TEST(S32x4Irregular) { | 1678 WASM_SIMD_TEST(S32x4Irregular) { |
1685 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 4, 4, 5}}); | 1679 RunBinaryLaneOpTest<int8_t>( |
1686 RunBinaryLaneOpTest<int32_t>(kExprS32x4Shuffle, {{0, 0, 0, 1}}); | 1680 kExprS8x16Shuffle, |
| 1681 {{0, 1, 2, 3, 16, 17, 18, 19, 16, 17, 18, 19, 20, 21, 22, 23}}); |
| 1682 RunBinaryLaneOpTest<int8_t>( |
| 1683 kExprS8x16Shuffle, {{0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 4, 5, 6, 7}}); |
1687 } | 1684 } |
1688 | 1685 |
1689 WASM_SIMD_TEST(S16x8ZipLeft) { | 1686 WASM_SIMD_TEST(S16x8ZipLeft) { |
1690 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 8, 1, 9, 2, 10, 3, 11}}); | 1687 RunBinaryLaneOpTest<int8_t>( |
1691 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 0, 1, 1, 2, 2, 3, 3}}); | 1688 kExprS8x16Shuffle, |
| 1689 {{0, 1, 16, 17, 2, 3, 18, 19, 4, 5, 20, 21, 6, 7, 22, 23}}); |
| 1690 RunBinaryLaneOpTest<int8_t>( |
| 1691 kExprS8x16Shuffle, {{0, 1, 0, 1, 2, 3, 2, 3, 4, 5, 4, 5, 6, 7, 6, 7}}); |
1692 } | 1692 } |
1693 | 1693 |
1694 WASM_SIMD_TEST(S16x8ZipRight) { | 1694 WASM_SIMD_TEST(S16x8ZipRight) { |
1695 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, | 1695 RunBinaryLaneOpTest<int8_t>( |
1696 {{4, 12, 5, 13, 6, 14, 7, 15}}); | 1696 kExprS8x16Shuffle, |
1697 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{4, 4, 5, 5, 6, 6, 7, 7}}); | 1697 {{8, 9, 24, 25, 10, 11, 26, 27, 12, 13, 28, 29, 14, 15, 30, 31}}); |
| 1698 RunBinaryLaneOpTest<int8_t>( |
| 1699 kExprS8x16Shuffle, |
| 1700 {{8, 9, 8, 9, 10, 11, 10, 11, 12, 13, 12, 13, 14, 15, 14, 15}}); |
1698 } | 1701 } |
1699 | 1702 |
1700 WASM_SIMD_TEST(S16x8UnzipLeft) { | 1703 WASM_SIMD_TEST(S16x8UnzipLeft) { |
1701 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, | 1704 RunBinaryLaneOpTest<int8_t>( |
1702 {{0, 2, 4, 6, 8, 10, 12, 14}}); | 1705 kExprS8x16Shuffle, |
1703 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 2, 4, 6, 0, 2, 4, 6}}); | 1706 {{0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29}}); |
| 1707 RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{0, 1, 4, 5, 8, 9, 12, 13, 0, |
| 1708 1, 4, 5, 8, 9, 12, 13}}); |
1704 } | 1709 } |
1705 | 1710 |
1706 WASM_SIMD_TEST(S16x8UnzipRight) { | 1711 WASM_SIMD_TEST(S16x8UnzipRight) { |
1707 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, | 1712 RunBinaryLaneOpTest<int8_t>( |
1708 {{1, 3, 5, 7, 9, 11, 13, 15}}); | 1713 kExprS8x16Shuffle, |
1709 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{1, 3, 5, 7, 1, 3, 5, 7}}); | 1714 {{2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31}}); |
| 1715 RunBinaryLaneOpTest<int8_t>( |
| 1716 kExprS8x16Shuffle, |
| 1717 {{2, 3, 6, 7, 10, 11, 14, 15, 2, 3, 6, 7, 10, 11, 14, 15}}); |
1710 } | 1718 } |
1711 | 1719 |
1712 WASM_SIMD_TEST(S16x8TransposeLeft) { | 1720 WASM_SIMD_TEST(S16x8TransposeLeft) { |
1713 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, | 1721 RunBinaryLaneOpTest<int8_t>( |
1714 {{0, 8, 2, 10, 4, 12, 6, 14}}); | 1722 kExprS8x16Shuffle, |
1715 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 0, 2, 2, 4, 4, 6, 6}}); | 1723 {{0, 1, 16, 17, 4, 5, 20, 21, 8, 9, 24, 25, 12, 13, 28, 29}}); |
| 1724 RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{0, 1, 0, 1, 4, 5, 4, 5, 8, 9, |
| 1725 8, 9, 12, 13, 12, 13}}); |
1716 } | 1726 } |
1717 | 1727 |
1718 WASM_SIMD_TEST(S16x8TransposeRight) { | 1728 WASM_SIMD_TEST(S16x8TransposeRight) { |
1719 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, | 1729 RunBinaryLaneOpTest<int8_t>( |
1720 {{1, 9, 3, 11, 5, 13, 7, 15}}); | 1730 kExprS8x16Shuffle, |
1721 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{1, 1, 3, 3, 5, 5, 7, 7}}); | 1731 {{2, 3, 18, 19, 6, 7, 22, 23, 10, 11, 26, 27, 14, 15, 30, 31}}); |
| 1732 RunBinaryLaneOpTest<int8_t>( |
| 1733 kExprS8x16Shuffle, |
| 1734 {{2, 3, 2, 3, 6, 7, 6, 7, 10, 11, 10, 11, 14, 15, 14, 15}}); |
1722 } | 1735 } |
1723 | 1736 |
1724 WASM_SIMD_TEST(S16x4Reverse) { | 1737 WASM_SIMD_TEST(S16x4Reverse) { |
1725 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{3, 2, 1, 0, 7, 6, 5, 4}}); | 1738 RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{6, 7, 4, 5, 2, 3, 0, 1, 14, |
| 1739 15, 12, 13, 10, 11, 8, 9}}); |
1726 } | 1740 } |
1727 | 1741 |
1728 WASM_SIMD_TEST(S16x2Reverse) { | 1742 WASM_SIMD_TEST(S16x2Reverse) { |
1729 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{1, 0, 3, 2, 5, 4, 7, 6}}); | 1743 RunBinaryLaneOpTest<int8_t>(kExprS8x16Shuffle, {{2, 3, 0, 1, 6, 7, 4, 5, 10, |
| 1744 11, 8, 9, 14, 15, 12, 13}}); |
1730 } | 1745 } |
1731 | 1746 |
1732 WASM_SIMD_TEST(S16x8Irregular) { | 1747 WASM_SIMD_TEST(S16x8Irregular) { |
1733 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 8, 8, 0, 2, 10, 3, 11}}); | 1748 RunBinaryLaneOpTest<int8_t>( |
1734 RunBinaryLaneOpTest<int16_t>(kExprS16x8Shuffle, {{0, 0, 0, 0, 2, 2, 3, 3}}); | 1749 kExprS8x16Shuffle, |
| 1750 {{0, 1, 16, 17, 16, 17, 0, 1, 4, 5, 20, 21, 6, 7, 22, 23}}); |
| 1751 RunBinaryLaneOpTest<int8_t>( |
| 1752 kExprS8x16Shuffle, {{0, 1, 0, 1, 0, 1, 0, 1, 4, 5, 4, 5, 6, 7, 6, 7}}); |
1735 } | 1753 } |
1736 | 1754 |
1737 WASM_SIMD_TEST(S8x16ZipLeft) { | 1755 WASM_SIMD_TEST(S8x16ZipLeft) { |
1738 RunBinaryLaneOpTest<int8_t>( | 1756 RunBinaryLaneOpTest<int8_t>( |
1739 kExprS8x16Shuffle, | 1757 kExprS8x16Shuffle, |
1740 {{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}}); | 1758 {{0, 16, 1, 17, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}}); |
1741 RunBinaryLaneOpTest<int8_t>( | 1759 RunBinaryLaneOpTest<int8_t>( |
1742 kExprS8x16Shuffle, {{0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}}); | 1760 kExprS8x16Shuffle, {{0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}}); |
1743 } | 1761 } |
1744 | 1762 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 | 1818 |
1801 WASM_SIMD_TEST(S8x16Irregular) { | 1819 WASM_SIMD_TEST(S8x16Irregular) { |
1802 RunBinaryLaneOpTest<int8_t>( | 1820 RunBinaryLaneOpTest<int8_t>( |
1803 kExprS8x16Shuffle, | 1821 kExprS8x16Shuffle, |
1804 {{0, 16, 0, 16, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}}); | 1822 {{0, 16, 0, 16, 2, 18, 3, 19, 4, 20, 5, 21, 6, 22, 7, 23}}); |
1805 RunBinaryLaneOpTest<int8_t>( | 1823 RunBinaryLaneOpTest<int8_t>( |
1806 kExprS8x16Shuffle, {{0, 0, 0, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}}); | 1824 kExprS8x16Shuffle, {{0, 0, 0, 0, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7}}); |
1807 } | 1825 } |
1808 | 1826 |
1809 // Test shuffles that concatenate the two vectors. | 1827 // Test shuffles that concatenate the two vectors. |
1810 template <typename T> | 1828 void RunConcatOpTest() {} |
1811 void RunConcatOpTest(WasmOpcode simd_op) { | 1829 |
1812 static const int kLanes = kSimd128Size / sizeof(T); | 1830 WASM_SIMD_TEST(S8x16Concat) { |
1813 std::array<T, kLanes> expected; | 1831 static const int kLanes = 16; |
| 1832 std::array<uint8_t, kLanes> expected; |
1814 for (int bias = 1; bias < kLanes; bias++) { | 1833 for (int bias = 1; bias < kLanes; bias++) { |
1815 int i = 0; | 1834 int i = 0; |
1816 // last kLanes - bias bytes of first vector. | 1835 // last kLanes - bias bytes of first vector. |
1817 for (int j = bias; j < kLanes; j++) { | 1836 for (int j = bias; j < kLanes; j++) { |
1818 expected[i++] = j; | 1837 expected[i++] = j; |
1819 } | 1838 } |
1820 // first bias lanes of second vector | 1839 // first bias lanes of second vector |
1821 for (int j = 0; j < bias; j++) { | 1840 for (int j = 0; j < bias; j++) { |
1822 expected[i++] = j + kLanes; | 1841 expected[i++] = j + kLanes; |
1823 } | 1842 } |
1824 RunBinaryLaneOpTest<T>(simd_op, expected); | 1843 RunBinaryLaneOpTest(kExprS8x16Shuffle, expected); |
1825 } | 1844 } |
1826 } | 1845 } |
1827 | |
1828 WASM_SIMD_TEST(S32x4Concat) { RunConcatOpTest<int32_t>(kExprS32x4Shuffle); } | |
1829 | |
1830 WASM_SIMD_TEST(S16x8Concat) { RunConcatOpTest<int16_t>(kExprS16x8Shuffle); } | |
1831 | |
1832 WASM_SIMD_TEST(S8x16Concat) { RunConcatOpTest<int8_t>(kExprS8x16Shuffle); } | |
1833 #endif // V8_TARGET_ARCH_ARM | 1846 #endif // V8_TARGET_ARCH_ARM |
1834 | 1847 |
1835 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 1848 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
1836 // Boolean unary operations are 'AllTrue' and 'AnyTrue', which return an integer | 1849 // Boolean unary operations are 'AllTrue' and 'AnyTrue', which return an integer |
1837 // result. Use relational ops on numeric vectors to create the boolean vector | 1850 // result. Use relational ops on numeric vectors to create the boolean vector |
1838 // test inputs. Test inputs with all true, all false, one true, and one false. | 1851 // test inputs. Test inputs with all true, all false, one true, and one false. |
1839 #define WASM_SIMD_BOOL_REDUCTION_TEST(format, lanes) \ | 1852 #define WASM_SIMD_BOOL_REDUCTION_TEST(format, lanes) \ |
1840 WASM_SIMD_TEST(ReductionTest##lanes) { \ | 1853 WASM_SIMD_TEST(ReductionTest##lanes) { \ |
1841 WasmRunner<int32_t> r(kExecuteCompiled); \ | 1854 WasmRunner<int32_t> r(kExecuteCompiled); \ |
1842 byte zero = r.AllocateLocal(kWasmS128); \ | 1855 byte zero = r.AllocateLocal(kWasmS128); \ |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2185 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); | 2198 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); |
2186 | 2199 |
2187 FOR_INT32_INPUTS(i) { | 2200 FOR_INT32_INPUTS(i) { |
2188 int32_t expected = *i; | 2201 int32_t expected = *i; |
2189 r.module().WriteMemory(&memory[0], expected); | 2202 r.module().WriteMemory(&memory[0], expected); |
2190 CHECK_EQ(expected, r.Call()); | 2203 CHECK_EQ(expected, r.Call()); |
2191 } | 2204 } |
2192 } | 2205 } |
2193 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64 || | 2206 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_X64 || |
2194 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 | 2207 // V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 |
OLD | NEW |