249 } else {
250 Assert.assertEquals(r[i], a[i], "at index #" + i);
251 }
252 }
253 }
254
255 static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) {
256 int i = 0, j = 0;
257 try {
258 for (; i < a.length; i += vector_len) {
259 for (j = 0; j < vector_len; j++) {
260 Assert.assertEquals(r[i+j], a[i+order[i+j]]);
261 }
262 }
263 } catch (AssertionError e) {
264 int idx = i + j;
265 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
266 }
267 }
268
269 static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) {
270 int i = 0, j = 0;
271 try {
272 for (; i < a.length; i += vector_len) {
273 for (j = 0; j < vector_len; j++) {
274 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
275 }
276 }
277 } catch (AssertionError e) {
278 int idx = i + j;
279 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
280 }
281 }
282
283 static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean[] mask, int vector_len) {
284 int i = 0, j = 0;
285 try {
286 for (; i < a.length; i += vector_len) {
287 for (j = 0; j < vector_len; j++) {
288 if (mask[j % SPECIES.length()])
882 try {
883 for (; i < r.length; i++) {
884 Assert.assertEquals(r[i], (long)(a[i+offs]));
885 }
886 } catch (AssertionError e) {
887 Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
888 }
889 }
890
891 static void assertArraysEquals(double[] r, byte[] a, int offs) {
892 int i = 0;
893 try {
894 for (; i < r.length; i++) {
895 Assert.assertEquals(r[i], (double)(a[i+offs]));
896 }
897 } catch (AssertionError e) {
898 Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
899 }
900 }
901
902
903 static byte bits(byte e) {
904 return e;
905 }
906
907 static final List<IntFunction<byte[]>> BYTE_GENERATORS = List.of(
908 withToString("byte[-i * 5]", (int s) -> {
909 return fill(s * BUFFER_REPS,
910 i -> (byte)(-i * 5));
911 }),
912 withToString("byte[i * 5]", (int s) -> {
913 return fill(s * BUFFER_REPS,
914 i -> (byte)(i * 5));
915 }),
916 withToString("byte[i + 1]", (int s) -> {
917 return fill(s * BUFFER_REPS,
918 i -> (((byte)(i + 1) == 0) ? 1 : (byte)(i + 1)));
919 }),
920 withToString("byte[cornerCaseValue(i)]", (int s) -> {
921 return fill(s * BUFFER_REPS,
922 i -> cornerCaseValue(i));
977 })).
978 toArray(Object[][]::new);
979 }
980
981 @DataProvider
982 public Object[][] byteUnaryOpProvider() {
983 return BYTE_GENERATORS.stream().
984 map(f -> new Object[]{f}).
985 toArray(Object[][]::new);
986 }
987
988 @DataProvider
989 public Object[][] byteUnaryOpMaskProvider() {
990 return BOOLEAN_MASK_GENERATORS.stream().
991 flatMap(fm -> BYTE_GENERATORS.stream().map(fa -> {
992 return new Object[] {fa, fm};
993 })).
994 toArray(Object[][]::new);
995 }
996
997
998
999 @DataProvider
1000 public Object[][] maskProvider() {
1001 return BOOLEAN_MASK_GENERATORS.stream().
1002 map(f -> new Object[]{f}).
1003 toArray(Object[][]::new);
1004 }
1005
1006 @DataProvider
1007 public Object[][] maskCompareOpProvider() {
1008 return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1009 toArray(Object[][]::new);
1010 }
1011
1012 @DataProvider
1013 public Object[][] shuffleProvider() {
1014 return INT_SHUFFLE_GENERATORS.stream().
1015 map(f -> new Object[]{f}).
1016 toArray(Object[][]::new);
1017 }
1018
1054
1055 @DataProvider
1056 public Object[][] byteUnaryOpSelectFromProvider() {
1057 return BYTE_SHUFFLE_GENERATORS.stream().
1058 flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
1059 return new Object[] {fa, fs};
1060 })).
1061 toArray(Object[][]::new);
1062 }
1063
1064 @DataProvider
1065 public Object[][] byteUnaryOpSelectFromMaskProvider() {
1066 return BOOLEAN_MASK_GENERATORS.stream().
1067 flatMap(fm -> BYTE_SHUFFLE_GENERATORS.stream().
1068 flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
1069 return new Object[] {fa, fs, fm};
1070 }))).
1071 toArray(Object[][]::new);
1072 }
1073
1074
1075 static final List<IntFunction<byte[]>> BYTE_COMPARE_GENERATORS = List.of(
1076 withToString("byte[i]", (int s) -> {
1077 return fill(s * BUFFER_REPS,
1078 i -> (byte)i);
1079 }),
1080 withToString("byte[i - length / 2]", (int s) -> {
1081 return fill(s * BUFFER_REPS,
1082 i -> (byte)(i - (s * BUFFER_REPS / 2)));
1083 }),
1084 withToString("byte[i + 1]", (int s) -> {
1085 return fill(s * BUFFER_REPS,
1086 i -> (byte)(i + 1));
1087 }),
1088 withToString("byte[i - 2]", (int s) -> {
1089 return fill(s * BUFFER_REPS,
1090 i -> (byte)(i - 2));
1091 }),
1092 withToString("byte[zigZag(i)]", (int s) -> {
1093 return fill(s * BUFFER_REPS,
1094 i -> i%3 == 0 ? (byte)i : (i%3 == 1 ? (byte)(i + 1) : (byte)(i - 2)));
1195 }
1196 }
1197 }
1198
1199 static void replaceZero(byte[] a, boolean[] mask, byte v) {
1200 for (int i = 0; i < a.length; i++) {
1201 if (mask[i % mask.length] && a[i] == 0) {
1202 a[i] = v;
1203 }
1204 }
1205 }
1206
1207 static byte ROL_scalar(byte a, byte b) {
1208 return (byte)(((((byte)a) & 0xFF) << (b & 7)) | ((((byte)a) & 0xFF) >>> (8 - (b & 7))));
1209 }
1210
1211 static byte ROR_scalar(byte a, byte b) {
1212 return (byte)(((((byte)a) & 0xFF) >>> (b & 7)) | ((((byte)a) & 0xFF) << (8 - (b & 7))));
1213 }
1214
1215 static boolean eq(byte a, byte b) {
1216 return a == b;
1217 }
1218
1219 static boolean neq(byte a, byte b) {
1220 return a != b;
1221 }
1222
1223 static boolean lt(byte a, byte b) {
1224 return a < b;
1225 }
1226
1227 static boolean le(byte a, byte b) {
1228 return a <= b;
1229 }
1230
1231 static boolean gt(byte a, byte b) {
1232 return a > b;
1233 }
1234
1344 @Test
1345 // Test div by 0.
1346 static void bitwiseDivByZeroSmokeTest() {
1347 try {
1348 ByteVector a = (ByteVector) SPECIES.broadcast(0).addIndex(1);
1349 ByteVector b = (ByteVector) SPECIES.broadcast(0);
1350 a.div(b);
1351 Assert.fail();
1352 } catch (ArithmeticException e) {
1353 }
1354
1355 try {
1356 ByteVector a = (ByteVector) SPECIES.broadcast(0).addIndex(1);
1357 ByteVector b = (ByteVector) SPECIES.broadcast(0);
1358 VectorMask<Byte> m = a.lt((byte) 1);
1359 a.div(b, m);
1360 Assert.fail();
1361 } catch (ArithmeticException e) {
1362 }
1363 }
1364 static byte ADD(byte a, byte b) {
1365 return (byte)(a + b);
1366 }
1367
1368 @Test(dataProvider = "byteBinaryOpProvider")
1369 static void ADDByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1370 byte[] a = fa.apply(SPECIES.length());
1371 byte[] b = fb.apply(SPECIES.length());
1372 byte[] r = fr.apply(SPECIES.length());
1373
1374 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1375 for (int i = 0; i < a.length; i += SPECIES.length()) {
1376 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1377 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1378 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1379 }
1380 }
1381
1382 assertArraysEquals(r, a, b, ByteMaxVectorTests::ADD);
1383 }
1384 static byte add(byte a, byte b) {
1385 return (byte)(a + b);
1386 }
1387
1388 @Test(dataProvider = "byteBinaryOpProvider")
1389 static void addByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1390 byte[] a = fa.apply(SPECIES.length());
1391 byte[] b = fb.apply(SPECIES.length());
1392 byte[] r = fr.apply(SPECIES.length());
1393
1394 for (int i = 0; i < a.length; i += SPECIES.length()) {
1395 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1396 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1397 av.add(bv).intoArray(r, i);
1398 }
1399
1400 assertArraysEquals(r, a, b, ByteMaxVectorTests::add);
1401 }
1402
1403 @Test(dataProvider = "byteBinaryOpMaskProvider")
1420 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ADD);
1421 }
1422
1423 @Test(dataProvider = "byteBinaryOpMaskProvider")
1424 static void addByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1425 IntFunction<boolean[]> fm) {
1426 byte[] a = fa.apply(SPECIES.length());
1427 byte[] b = fb.apply(SPECIES.length());
1428 byte[] r = fr.apply(SPECIES.length());
1429 boolean[] mask = fm.apply(SPECIES.length());
1430 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1431
1432 for (int i = 0; i < a.length; i += SPECIES.length()) {
1433 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1434 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1435 av.add(bv, vmask).intoArray(r, i);
1436 }
1437
1438 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::add);
1439 }
1440 static byte SUB(byte a, byte b) {
1441 return (byte)(a - b);
1442 }
1443
1444 @Test(dataProvider = "byteBinaryOpProvider")
1445 static void SUBByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1446 byte[] a = fa.apply(SPECIES.length());
1447 byte[] b = fb.apply(SPECIES.length());
1448 byte[] r = fr.apply(SPECIES.length());
1449
1450 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1451 for (int i = 0; i < a.length; i += SPECIES.length()) {
1452 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1453 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1454 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1455 }
1456 }
1457
1458 assertArraysEquals(r, a, b, ByteMaxVectorTests::SUB);
1459 }
1460 static byte sub(byte a, byte b) {
1461 return (byte)(a - b);
1462 }
1463
1464 @Test(dataProvider = "byteBinaryOpProvider")
1465 static void subByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1466 byte[] a = fa.apply(SPECIES.length());
1467 byte[] b = fb.apply(SPECIES.length());
1468 byte[] r = fr.apply(SPECIES.length());
1469
1470 for (int i = 0; i < a.length; i += SPECIES.length()) {
1471 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1472 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1473 av.sub(bv).intoArray(r, i);
1474 }
1475
1476 assertArraysEquals(r, a, b, ByteMaxVectorTests::sub);
1477 }
1478
1479 @Test(dataProvider = "byteBinaryOpMaskProvider")
1496 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SUB);
1497 }
1498
1499 @Test(dataProvider = "byteBinaryOpMaskProvider")
1500 static void subByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1501 IntFunction<boolean[]> fm) {
1502 byte[] a = fa.apply(SPECIES.length());
1503 byte[] b = fb.apply(SPECIES.length());
1504 byte[] r = fr.apply(SPECIES.length());
1505 boolean[] mask = fm.apply(SPECIES.length());
1506 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1507
1508 for (int i = 0; i < a.length; i += SPECIES.length()) {
1509 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1510 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1511 av.sub(bv, vmask).intoArray(r, i);
1512 }
1513
1514 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::sub);
1515 }
1516 static byte MUL(byte a, byte b) {
1517 return (byte)(a * b);
1518 }
1519
1520 @Test(dataProvider = "byteBinaryOpProvider")
1521 static void MULByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1522 byte[] a = fa.apply(SPECIES.length());
1523 byte[] b = fb.apply(SPECIES.length());
1524 byte[] r = fr.apply(SPECIES.length());
1525
1526 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1527 for (int i = 0; i < a.length; i += SPECIES.length()) {
1528 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1529 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1530 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1531 }
1532 }
1533
1534 assertArraysEquals(r, a, b, ByteMaxVectorTests::MUL);
1535 }
1536 static byte mul(byte a, byte b) {
1537 return (byte)(a * b);
1538 }
1539
1540 @Test(dataProvider = "byteBinaryOpProvider")
1541 static void mulByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1542 byte[] a = fa.apply(SPECIES.length());
1543 byte[] b = fb.apply(SPECIES.length());
1544 byte[] r = fr.apply(SPECIES.length());
1545
1546 for (int i = 0; i < a.length; i += SPECIES.length()) {
1547 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1548 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1549 av.mul(bv).intoArray(r, i);
1550 }
1551
1552 assertArraysEquals(r, a, b, ByteMaxVectorTests::mul);
1553 }
1554
1555 @Test(dataProvider = "byteBinaryOpMaskProvider")
1573 }
1574
1575 @Test(dataProvider = "byteBinaryOpMaskProvider")
1576 static void mulByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1577 IntFunction<boolean[]> fm) {
1578 byte[] a = fa.apply(SPECIES.length());
1579 byte[] b = fb.apply(SPECIES.length());
1580 byte[] r = fr.apply(SPECIES.length());
1581 boolean[] mask = fm.apply(SPECIES.length());
1582 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1583
1584 for (int i = 0; i < a.length; i += SPECIES.length()) {
1585 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1586 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1587 av.mul(bv, vmask).intoArray(r, i);
1588 }
1589
1590 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::mul);
1591 }
1592
1593
1594
1595 static byte DIV(byte a, byte b) {
1596 return (byte)(a / b);
1597 }
1598
1599 @Test(dataProvider = "byteBinaryOpProvider")
1600 static void DIVByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1601 byte[] a = fa.apply(SPECIES.length());
1602 byte[] b = fb.apply(SPECIES.length());
1603 byte[] r = fr.apply(SPECIES.length());
1604
1605 replaceZero(b, (byte) 1);
1606
1607 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1608 for (int i = 0; i < a.length; i += SPECIES.length()) {
1609 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1610 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1611 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1612 }
1613 }
1614
1615 assertArraysEquals(r, a, b, ByteMaxVectorTests::DIV);
1616 }
1617 static byte div(byte a, byte b) {
1618 return (byte)(a / b);
1619 }
1620
1621 @Test(dataProvider = "byteBinaryOpProvider")
1622 static void divByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1623 byte[] a = fa.apply(SPECIES.length());
1624 byte[] b = fb.apply(SPECIES.length());
1625 byte[] r = fr.apply(SPECIES.length());
1626
1627 replaceZero(b, (byte) 1);
1628
1629 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1630 for (int i = 0; i < a.length; i += SPECIES.length()) {
1631 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1632 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1633 av.div(bv).intoArray(r, i);
1634 }
1635 }
1636
1637 assertArraysEquals(r, a, b, ByteMaxVectorTests::div);
1638 }
1639
1640
1641
1642 @Test(dataProvider = "byteBinaryOpMaskProvider")
1643 static void DIVByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1644 IntFunction<boolean[]> fm) {
1645 byte[] a = fa.apply(SPECIES.length());
1646 byte[] b = fb.apply(SPECIES.length());
1647 byte[] r = fr.apply(SPECIES.length());
1648 boolean[] mask = fm.apply(SPECIES.length());
1649 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1650
1651 replaceZero(b, mask, (byte) 1);
1652
1653 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1654 for (int i = 0; i < a.length; i += SPECIES.length()) {
1655 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1656 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1657 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1658 }
1659 }
1660
1661 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::DIV);
1727 static byte AND(byte a, byte b) {
1728 return (byte)(a & b);
1729 }
1730
1731 @Test(dataProvider = "byteBinaryOpProvider")
1732 static void ANDByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1733 byte[] a = fa.apply(SPECIES.length());
1734 byte[] b = fb.apply(SPECIES.length());
1735 byte[] r = fr.apply(SPECIES.length());
1736
1737 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1738 for (int i = 0; i < a.length; i += SPECIES.length()) {
1739 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1740 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1741 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1742 }
1743 }
1744
1745 assertArraysEquals(r, a, b, ByteMaxVectorTests::AND);
1746 }
1747 static byte and(byte a, byte b) {
1748 return (byte)(a & b);
1749 }
1750
1751 @Test(dataProvider = "byteBinaryOpProvider")
1752 static void andByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1753 byte[] a = fa.apply(SPECIES.length());
1754 byte[] b = fb.apply(SPECIES.length());
1755 byte[] r = fr.apply(SPECIES.length());
1756
1757 for (int i = 0; i < a.length; i += SPECIES.length()) {
1758 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1759 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1760 av.and(bv).intoArray(r, i);
1761 }
1762
1763 assertArraysEquals(r, a, b, ByteMaxVectorTests::and);
1764 }
1765
1766
1767
1768 @Test(dataProvider = "byteBinaryOpMaskProvider")
1769 static void ANDByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1770 IntFunction<boolean[]> fm) {
1771 byte[] a = fa.apply(SPECIES.length());
1772 byte[] b = fb.apply(SPECIES.length());
1773 byte[] r = fr.apply(SPECIES.length());
1774 boolean[] mask = fm.apply(SPECIES.length());
1775 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1776
1777 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1778 for (int i = 0; i < a.length; i += SPECIES.length()) {
1779 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1780 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1781 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
1782 }
1783 }
1784
1785 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND);
1786 }
1787
1788
1789 static byte AND_NOT(byte a, byte b) {
1790 return (byte)(a & ~b);
1791 }
1792
1793 @Test(dataProvider = "byteBinaryOpProvider")
1794 static void AND_NOTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1795 byte[] a = fa.apply(SPECIES.length());
1796 byte[] b = fb.apply(SPECIES.length());
1797 byte[] r = fr.apply(SPECIES.length());
1798
1799 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1800 for (int i = 0; i < a.length; i += SPECIES.length()) {
1801 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1802 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1803 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
1804 }
1805 }
1806
1807 assertArraysEquals(r, a, b, ByteMaxVectorTests::AND_NOT);
1808 }
1809
1810
1811
1812 @Test(dataProvider = "byteBinaryOpMaskProvider")
1813 static void AND_NOTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1814 IntFunction<boolean[]> fm) {
1815 byte[] a = fa.apply(SPECIES.length());
1816 byte[] b = fb.apply(SPECIES.length());
1817 byte[] r = fr.apply(SPECIES.length());
1818 boolean[] mask = fm.apply(SPECIES.length());
1819 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1820
1821 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1822 for (int i = 0; i < a.length; i += SPECIES.length()) {
1823 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1824 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1825 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
1826 }
1827 }
1828
1829 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND_NOT);
1830 }
1831
1832
1833 static byte OR(byte a, byte b) {
1834 return (byte)(a | b);
1835 }
1836
1837 @Test(dataProvider = "byteBinaryOpProvider")
1838 static void ORByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1839 byte[] a = fa.apply(SPECIES.length());
1840 byte[] b = fb.apply(SPECIES.length());
1841 byte[] r = fr.apply(SPECIES.length());
1842
1843 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1844 for (int i = 0; i < a.length; i += SPECIES.length()) {
1845 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1846 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1847 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1848 }
1849 }
1850
1851 assertArraysEquals(r, a, b, ByteMaxVectorTests::OR);
1852 }
1853 static byte or(byte a, byte b) {
1854 return (byte)(a | b);
1855 }
1856
1857 @Test(dataProvider = "byteBinaryOpProvider")
1858 static void orByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1859 byte[] a = fa.apply(SPECIES.length());
1860 byte[] b = fb.apply(SPECIES.length());
1861 byte[] r = fr.apply(SPECIES.length());
1862
1863 for (int i = 0; i < a.length; i += SPECIES.length()) {
1864 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1865 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1866 av.or(bv).intoArray(r, i);
1867 }
1868
1869 assertArraysEquals(r, a, b, ByteMaxVectorTests::or);
1870 }
1871
1872
1873
1874 @Test(dataProvider = "byteBinaryOpMaskProvider")
1875 static void ORByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1876 IntFunction<boolean[]> fm) {
1877 byte[] a = fa.apply(SPECIES.length());
1878 byte[] b = fb.apply(SPECIES.length());
1879 byte[] r = fr.apply(SPECIES.length());
1880 boolean[] mask = fm.apply(SPECIES.length());
1881 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1882
1883 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1884 for (int i = 0; i < a.length; i += SPECIES.length()) {
1885 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1886 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1887 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1888 }
1889 }
1890
1891 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR);
1892 }
1893
1894
1895 static byte XOR(byte a, byte b) {
1896 return (byte)(a ^ b);
1897 }
1898
1899 @Test(dataProvider = "byteBinaryOpProvider")
1900 static void XORByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1901 byte[] a = fa.apply(SPECIES.length());
1902 byte[] b = fb.apply(SPECIES.length());
1903 byte[] r = fr.apply(SPECIES.length());
1904
1905 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1906 for (int i = 0; i < a.length; i += SPECIES.length()) {
1907 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1908 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1909 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
1910 }
1911 }
1912
1913 assertArraysEquals(r, a, b, ByteMaxVectorTests::XOR);
1914 }
1915
1916
1917
1918 @Test(dataProvider = "byteBinaryOpMaskProvider")
1919 static void XORByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1920 IntFunction<boolean[]> fm) {
1921 byte[] a = fa.apply(SPECIES.length());
1922 byte[] b = fb.apply(SPECIES.length());
1923 byte[] r = fr.apply(SPECIES.length());
1924 boolean[] mask = fm.apply(SPECIES.length());
1925 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1926
1927 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1928 for (int i = 0; i < a.length; i += SPECIES.length()) {
1929 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1930 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1931 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1932 }
1933 }
1934
1935 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::XOR);
1936 }
1937
1938
1939 @Test(dataProvider = "byteBinaryOpProvider")
1940 static void addByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1941 byte[] a = fa.apply(SPECIES.length());
1942 byte[] b = fb.apply(SPECIES.length());
1943 byte[] r = fr.apply(SPECIES.length());
1944
1945 for (int i = 0; i < a.length; i += SPECIES.length()) {
1946 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1947 av.add(b[i]).intoArray(r, i);
1948 }
1949
1950 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::add);
1951 }
1952
1953 @Test(dataProvider = "byteBinaryOpMaskProvider")
1954 static void addByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1955 IntFunction<boolean[]> fm) {
1956 byte[] a = fa.apply(SPECIES.length());
1957 byte[] b = fb.apply(SPECIES.length());
1958 byte[] r = fr.apply(SPECIES.length());
2012 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::mul);
2013 }
2014
2015 @Test(dataProvider = "byteBinaryOpMaskProvider")
2016 static void mulByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2017 IntFunction<boolean[]> fm) {
2018 byte[] a = fa.apply(SPECIES.length());
2019 byte[] b = fb.apply(SPECIES.length());
2020 byte[] r = fr.apply(SPECIES.length());
2021 boolean[] mask = fm.apply(SPECIES.length());
2022 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2023
2024 for (int i = 0; i < a.length; i += SPECIES.length()) {
2025 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2026 av.mul(b[i], vmask).intoArray(r, i);
2027 }
2028
2029 assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::mul);
2030 }
2031
2032
2033
2034
2035 @Test(dataProvider = "byteBinaryOpProvider")
2036 static void divByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2037 byte[] a = fa.apply(SPECIES.length());
2038 byte[] b = fb.apply(SPECIES.length());
2039 byte[] r = fr.apply(SPECIES.length());
2040
2041 replaceZero(b, (byte) 1);
2042
2043 for (int i = 0; i < a.length; i += SPECIES.length()) {
2044 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2045 av.div(b[i]).intoArray(r, i);
2046 }
2047
2048 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::div);
2049 }
2050
2051
2052
2053 @Test(dataProvider = "byteBinaryOpMaskProvider")
2054 static void divByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2055 IntFunction<boolean[]> fm) {
2056 byte[] a = fa.apply(SPECIES.length());
2057 byte[] b = fb.apply(SPECIES.length());
2058 byte[] r = fr.apply(SPECIES.length());
2059 boolean[] mask = fm.apply(SPECIES.length());
2060 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2061
2062 replaceZero(b, (byte) 1);
2063
2064 for (int i = 0; i < a.length; i += SPECIES.length()) {
2065 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2066 av.div(b[i], vmask).intoArray(r, i);
2067 }
2068
2069 assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::div);
2070 }
2071
2072
2073
2074 @Test(dataProvider = "byteBinaryOpProvider")
2075 static void ORByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2076 byte[] a = fa.apply(SPECIES.length());
2077 byte[] b = fb.apply(SPECIES.length());
2078 byte[] r = fr.apply(SPECIES.length());
2079
2080 for (int i = 0; i < a.length; i += SPECIES.length()) {
2081 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2082 av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2083 }
2084
2085 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::OR);
2086 }
2087
2088 @Test(dataProvider = "byteBinaryOpProvider")
2089 static void orByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2090 byte[] a = fa.apply(SPECIES.length());
2091 byte[] b = fb.apply(SPECIES.length());
2092 byte[] r = fr.apply(SPECIES.length());
2093
2094 for (int i = 0; i < a.length; i += SPECIES.length()) {
2095 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2096 av.or(b[i]).intoArray(r, i);
2097 }
2098
2099 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::or);
2100 }
2101
2102
2103
2104 @Test(dataProvider = "byteBinaryOpMaskProvider")
2105 static void ORByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2106 IntFunction<boolean[]> fm) {
2107 byte[] a = fa.apply(SPECIES.length());
2108 byte[] b = fb.apply(SPECIES.length());
2109 byte[] r = fr.apply(SPECIES.length());
2110 boolean[] mask = fm.apply(SPECIES.length());
2111 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2112
2113 for (int i = 0; i < a.length; i += SPECIES.length()) {
2114 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2115 av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2116 }
2117
2118 assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR);
2119 }
2120
2121
2122
2123 @Test(dataProvider = "byteBinaryOpProvider")
2124 static void ANDByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2125 byte[] a = fa.apply(SPECIES.length());
2126 byte[] b = fb.apply(SPECIES.length());
2127 byte[] r = fr.apply(SPECIES.length());
2128
2129 for (int i = 0; i < a.length; i += SPECIES.length()) {
2130 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2131 av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2132 }
2133
2134 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::AND);
2135 }
2136
2137 @Test(dataProvider = "byteBinaryOpProvider")
2138 static void andByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2139 byte[] a = fa.apply(SPECIES.length());
2140 byte[] b = fb.apply(SPECIES.length());
2141 byte[] r = fr.apply(SPECIES.length());
2142
2143 for (int i = 0; i < a.length; i += SPECIES.length()) {
2144 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2145 av.and(b[i]).intoArray(r, i);
2146 }
2147
2148 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::and);
2149 }
2150
2151
2152
2153 @Test(dataProvider = "byteBinaryOpMaskProvider")
2154 static void ANDByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2155 IntFunction<boolean[]> fm) {
2156 byte[] a = fa.apply(SPECIES.length());
2157 byte[] b = fb.apply(SPECIES.length());
2158 byte[] r = fr.apply(SPECIES.length());
2159 boolean[] mask = fm.apply(SPECIES.length());
2160 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2161
2162 for (int i = 0; i < a.length; i += SPECIES.length()) {
2163 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2164 av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2165 }
2166
2167 assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND);
2168 }
2169
2170
2171
2172 @Test(dataProvider = "byteBinaryOpProvider")
2173 static void ORByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2174 byte[] a = fa.apply(SPECIES.length());
2175 byte[] b = fb.apply(SPECIES.length());
2176 byte[] r = fr.apply(SPECIES.length());
2177
2178 for (int i = 0; i < a.length; i += SPECIES.length()) {
2179 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2180 av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2181 }
2182
2183 assertBroadcastLongArraysEquals(r, a, b, ByteMaxVectorTests::OR);
2184 }
2185
2186
2187
2188 @Test(dataProvider = "byteBinaryOpMaskProvider")
2189 static void ORByteMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2190 IntFunction<boolean[]> fm) {
2191 byte[] a = fa.apply(SPECIES.length());
2192 byte[] b = fb.apply(SPECIES.length());
2193 byte[] r = fr.apply(SPECIES.length());
2194 boolean[] mask = fm.apply(SPECIES.length());
2195 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2196
2197 for (int i = 0; i < a.length; i += SPECIES.length()) {
2198 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2199 av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2200 }
2201
2202 assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR);
2203 }
2204
2205
2206 @Test(dataProvider = "byteBinaryOpProvider")
2207 static void ADDByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2208 byte[] a = fa.apply(SPECIES.length());
2209 byte[] b = fb.apply(SPECIES.length());
2210 byte[] r = fr.apply(SPECIES.length());
2211
2212 for (int i = 0; i < a.length; i += SPECIES.length()) {
2213 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2214 av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2215 }
2216
2217 assertBroadcastLongArraysEquals(r, a, b, ByteMaxVectorTests::ADD);
2218 }
2219
2220 @Test(dataProvider = "byteBinaryOpMaskProvider")
2221 static void ADDByteMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2222 IntFunction<boolean[]> fm) {
2223 byte[] a = fa.apply(SPECIES.length());
2224 byte[] b = fb.apply(SPECIES.length());
2225 byte[] r = fr.apply(SPECIES.length());
2226 boolean[] mask = fm.apply(SPECIES.length());
2227 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2228
2229 for (int i = 0; i < a.length; i += SPECIES.length()) {
2230 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2231 av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
2232 }
2233
2234 assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::ADD);
2235 }
2236
2237
2238
2239 static byte LSHL(byte a, byte b) {
2240 return (byte)((a << (b & 0x7)));
2241 }
2242
2243 @Test(dataProvider = "byteBinaryOpProvider")
2244 static void LSHLByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2245 byte[] a = fa.apply(SPECIES.length());
2246 byte[] b = fb.apply(SPECIES.length());
2247 byte[] r = fr.apply(SPECIES.length());
2248
2249 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2250 for (int i = 0; i < a.length; i += SPECIES.length()) {
2251 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2252 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2253 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2254 }
2255 }
2256
2257 assertArraysEquals(r, a, b, ByteMaxVectorTests::LSHL);
2258 }
2259
2260
2261
2262 @Test(dataProvider = "byteBinaryOpMaskProvider")
2263 static void LSHLByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2264 IntFunction<boolean[]> fm) {
2265 byte[] a = fa.apply(SPECIES.length());
2266 byte[] b = fb.apply(SPECIES.length());
2267 byte[] r = fr.apply(SPECIES.length());
2268 boolean[] mask = fm.apply(SPECIES.length());
2269 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2270
2271 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2272 for (int i = 0; i < a.length; i += SPECIES.length()) {
2273 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2274 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2275 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2276 }
2277 }
2278
2279 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHL);
2280 }
2281
2282
2283
2284
2285
2286
2287 static byte ASHR(byte a, byte b) {
2288 return (byte)((a >> (b & 0x7)));
2289 }
2290
2291 @Test(dataProvider = "byteBinaryOpProvider")
2292 static void ASHRByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2293 byte[] a = fa.apply(SPECIES.length());
2294 byte[] b = fb.apply(SPECIES.length());
2295 byte[] r = fr.apply(SPECIES.length());
2296
2297 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2298 for (int i = 0; i < a.length; i += SPECIES.length()) {
2299 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2300 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2301 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2302 }
2303 }
2304
2305 assertArraysEquals(r, a, b, ByteMaxVectorTests::ASHR);
2306 }
2307
2308
2309
2310 @Test(dataProvider = "byteBinaryOpMaskProvider")
2311 static void ASHRByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2312 IntFunction<boolean[]> fm) {
2313 byte[] a = fa.apply(SPECIES.length());
2314 byte[] b = fb.apply(SPECIES.length());
2315 byte[] r = fr.apply(SPECIES.length());
2316 boolean[] mask = fm.apply(SPECIES.length());
2317 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2318
2319 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2320 for (int i = 0; i < a.length; i += SPECIES.length()) {
2321 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2322 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2323 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2324 }
2325 }
2326
2327 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ASHR);
2328 }
2329
2330
2331
2332
2333
2334
2335 static byte LSHR(byte a, byte b) {
2336 return (byte)(((a & 0xFF) >>> (b & 0x7)));
2337 }
2338
2339 @Test(dataProvider = "byteBinaryOpProvider")
2340 static void LSHRByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2341 byte[] a = fa.apply(SPECIES.length());
2342 byte[] b = fb.apply(SPECIES.length());
2343 byte[] r = fr.apply(SPECIES.length());
2344
2345 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2346 for (int i = 0; i < a.length; i += SPECIES.length()) {
2347 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2348 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2349 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2350 }
2351 }
2352
2353 assertArraysEquals(r, a, b, ByteMaxVectorTests::LSHR);
2354 }
2355
2356
2357
2358 @Test(dataProvider = "byteBinaryOpMaskProvider")
2359 static void LSHRByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2360 IntFunction<boolean[]> fm) {
2361 byte[] a = fa.apply(SPECIES.length());
2362 byte[] b = fb.apply(SPECIES.length());
2363 byte[] r = fr.apply(SPECIES.length());
2364 boolean[] mask = fm.apply(SPECIES.length());
2365 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2366
2367 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2368 for (int i = 0; i < a.length; i += SPECIES.length()) {
2369 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2370 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2371 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2372 }
2373 }
2374
2375 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHR);
2376 }
2377
2378
2379
2380
2381
2382
2383 static byte LSHL_unary(byte a, byte b) {
2384 return (byte)((a << (b & 7)));
2385 }
2386
2387 @Test(dataProvider = "byteBinaryOpProvider")
2388 static void LSHLByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2389 byte[] a = fa.apply(SPECIES.length());
2390 byte[] b = fb.apply(SPECIES.length());
2391 byte[] r = fr.apply(SPECIES.length());
2392
2393 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2394 for (int i = 0; i < a.length; i += SPECIES.length()) {
2395 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2396 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2397 }
2398 }
2399
2400 assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::LSHL_unary);
2401 }
2402
2403
2404
2405 @Test(dataProvider = "byteBinaryOpMaskProvider")
2406 static void LSHLByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2407 IntFunction<boolean[]> fm) {
2408 byte[] a = fa.apply(SPECIES.length());
2409 byte[] b = fb.apply(SPECIES.length());
2410 byte[] r = fr.apply(SPECIES.length());
2411 boolean[] mask = fm.apply(SPECIES.length());
2412 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2413
2414 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2415 for (int i = 0; i < a.length; i += SPECIES.length()) {
2416 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2417 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2418 }
2419 }
2420
2421 assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHL_unary);
2422 }
2423
2424
2425
2426
2427
2428
2429 static byte LSHR_unary(byte a, byte b) {
2430 return (byte)(((a & 0xFF) >>> (b & 7)));
2431 }
2432
2433 @Test(dataProvider = "byteBinaryOpProvider")
2434 static void LSHRByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2435 byte[] a = fa.apply(SPECIES.length());
2436 byte[] b = fb.apply(SPECIES.length());
2437 byte[] r = fr.apply(SPECIES.length());
2438
2439 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2440 for (int i = 0; i < a.length; i += SPECIES.length()) {
2441 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2442 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2443 }
2444 }
2445
2446 assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::LSHR_unary);
2447 }
2448
2449
2450
2451 @Test(dataProvider = "byteBinaryOpMaskProvider")
2452 static void LSHRByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2453 IntFunction<boolean[]> fm) {
2454 byte[] a = fa.apply(SPECIES.length());
2455 byte[] b = fb.apply(SPECIES.length());
2456 byte[] r = fr.apply(SPECIES.length());
2457 boolean[] mask = fm.apply(SPECIES.length());
2458 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2459
2460 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2461 for (int i = 0; i < a.length; i += SPECIES.length()) {
2462 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2463 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2464 }
2465 }
2466
2467 assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHR_unary);
2468 }
2469
2470
2471
2472
2473
2474
2475 static byte ASHR_unary(byte a, byte b) {
2476 return (byte)((a >> (b & 7)));
2477 }
2478
2479 @Test(dataProvider = "byteBinaryOpProvider")
2480 static void ASHRByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2481 byte[] a = fa.apply(SPECIES.length());
2482 byte[] b = fb.apply(SPECIES.length());
2483 byte[] r = fr.apply(SPECIES.length());
2484
2485 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2486 for (int i = 0; i < a.length; i += SPECIES.length()) {
2487 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2488 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2489 }
2490 }
2491
2492 assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ASHR_unary);
2493 }
2494
2495
2496
2497 @Test(dataProvider = "byteBinaryOpMaskProvider")
2498 static void ASHRByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2499 IntFunction<boolean[]> fm) {
2500 byte[] a = fa.apply(SPECIES.length());
2501 byte[] b = fb.apply(SPECIES.length());
2502 byte[] r = fr.apply(SPECIES.length());
2503 boolean[] mask = fm.apply(SPECIES.length());
2504 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2505
2506 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2507 for (int i = 0; i < a.length; i += SPECIES.length()) {
2508 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2509 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2510 }
2511 }
2512
2513 assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ASHR_unary);
2514 }
2515
2516
2517
2518
2519 static byte ROR(byte a, byte b) {
2520 return (byte)(ROR_scalar(a,b));
2521 }
2522
2523 @Test(dataProvider = "byteBinaryOpProvider")
2524 static void RORByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2525 byte[] a = fa.apply(SPECIES.length());
2526 byte[] b = fb.apply(SPECIES.length());
2527 byte[] r = fr.apply(SPECIES.length());
2528
2529 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2530 for (int i = 0; i < a.length; i += SPECIES.length()) {
2531 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2532 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2533 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2534 }
2535 }
2536
2537 assertArraysEquals(r, a, b, ByteMaxVectorTests::ROR);
2538 }
2539
2540
2541
2542 @Test(dataProvider = "byteBinaryOpMaskProvider")
2543 static void RORByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2544 IntFunction<boolean[]> fm) {
2545 byte[] a = fa.apply(SPECIES.length());
2546 byte[] b = fb.apply(SPECIES.length());
2547 byte[] r = fr.apply(SPECIES.length());
2548 boolean[] mask = fm.apply(SPECIES.length());
2549 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2550
2551 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2552 for (int i = 0; i < a.length; i += SPECIES.length()) {
2553 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2554 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2555 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2556 }
2557 }
2558
2559 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROR);
2560 }
2561
2562
2563 static byte ROL(byte a, byte b) {
2564 return (byte)(ROL_scalar(a,b));
2565 }
2566
2567 @Test(dataProvider = "byteBinaryOpProvider")
2568 static void ROLByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2569 byte[] a = fa.apply(SPECIES.length());
2570 byte[] b = fb.apply(SPECIES.length());
2571 byte[] r = fr.apply(SPECIES.length());
2572
2573 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2574 for (int i = 0; i < a.length; i += SPECIES.length()) {
2575 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2576 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2577 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2578 }
2579 }
2580
2581 assertArraysEquals(r, a, b, ByteMaxVectorTests::ROL);
2582 }
2583
2584
2585
2586 @Test(dataProvider = "byteBinaryOpMaskProvider")
2587 static void ROLByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2588 IntFunction<boolean[]> fm) {
2589 byte[] a = fa.apply(SPECIES.length());
2590 byte[] b = fb.apply(SPECIES.length());
2591 byte[] r = fr.apply(SPECIES.length());
2592 boolean[] mask = fm.apply(SPECIES.length());
2593 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2594
2595 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2596 for (int i = 0; i < a.length; i += SPECIES.length()) {
2597 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2598 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2599 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2600 }
2601 }
2602
2603 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROL);
2604 }
2605
2606
2607 static byte ROR_unary(byte a, byte b) {
2608 return (byte)(ROR_scalar(a, b));
2609 }
2610
2611 @Test(dataProvider = "byteBinaryOpProvider")
2612 static void RORByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2613 byte[] a = fa.apply(SPECIES.length());
2614 byte[] b = fb.apply(SPECIES.length());
2615 byte[] r = fr.apply(SPECIES.length());
2616
2617 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2618 for (int i = 0; i < a.length; i += SPECIES.length()) {
2619 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2620 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2621 }
2622 }
2623
2624 assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ROR_unary);
2625 }
2626
2627
2628
2629 @Test(dataProvider = "byteBinaryOpMaskProvider")
2630 static void RORByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2631 IntFunction<boolean[]> fm) {
2632 byte[] a = fa.apply(SPECIES.length());
2633 byte[] b = fb.apply(SPECIES.length());
2634 byte[] r = fr.apply(SPECIES.length());
2635 boolean[] mask = fm.apply(SPECIES.length());
2636 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2637
2638 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2639 for (int i = 0; i < a.length; i += SPECIES.length()) {
2640 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2641 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2642 }
2643 }
2644
2645 assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROR_unary);
2646 }
2647
2648
2649 static byte ROL_unary(byte a, byte b) {
2650 return (byte)(ROL_scalar(a, b));
2651 }
2652
2653 @Test(dataProvider = "byteBinaryOpProvider")
2654 static void ROLByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2655 byte[] a = fa.apply(SPECIES.length());
2656 byte[] b = fb.apply(SPECIES.length());
2657 byte[] r = fr.apply(SPECIES.length());
2658
2659 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2660 for (int i = 0; i < a.length; i += SPECIES.length()) {
2661 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2662 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2663 }
2664 }
2665
2666 assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ROL_unary);
2667 }
2668
2669
2670
2671 @Test(dataProvider = "byteBinaryOpMaskProvider")
2672 static void ROLByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2673 IntFunction<boolean[]> fm) {
2674 byte[] a = fa.apply(SPECIES.length());
2675 byte[] b = fb.apply(SPECIES.length());
2676 byte[] r = fr.apply(SPECIES.length());
2677 boolean[] mask = fm.apply(SPECIES.length());
2678 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2679
2680 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2681 for (int i = 0; i < a.length; i += SPECIES.length()) {
2682 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2683 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2684 }
2685 }
2686
2687 assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROL_unary);
2688 }
2689
2690
2691
2692
2693 static byte LSHR_binary_const(byte a) {
2694 return (byte)(((a & 0xFF) >>> CONST_SHIFT));
2695 }
2696
2697 @Test(dataProvider = "byteUnaryOpProvider")
2698 static void LSHRByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2699 byte[] a = fa.apply(SPECIES.length());
2700 byte[] r = fr.apply(SPECIES.length());
2701
2702 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2703 for (int i = 0; i < a.length; i += SPECIES.length()) {
2704 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2705 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
2706 }
2707 }
2708
2709 assertShiftConstEquals(r, a, ByteMaxVectorTests::LSHR_binary_const);
2710 }
2711
2712
2713
2714 @Test(dataProvider = "byteUnaryOpMaskProvider")
2715 static void LSHRByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2716 IntFunction<boolean[]> fm) {
2717 byte[] a = fa.apply(SPECIES.length());
2718 byte[] r = fr.apply(SPECIES.length());
2719 boolean[] mask = fm.apply(SPECIES.length());
2720 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2721
2722 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2723 for (int i = 0; i < a.length; i += SPECIES.length()) {
2724 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2725 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
2726 }
2727 }
2728
2729 assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::LSHR_binary_const);
2730 }
2731
2732
2733
2734
2735
2736 static byte LSHL_binary_const(byte a) {
2737 return (byte)((a << CONST_SHIFT));
2738 }
2739
2740 @Test(dataProvider = "byteUnaryOpProvider")
2741 static void LSHLByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2742 byte[] a = fa.apply(SPECIES.length());
2743 byte[] r = fr.apply(SPECIES.length());
2744
2745 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2746 for (int i = 0; i < a.length; i += SPECIES.length()) {
2747 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2748 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
2749 }
2750 }
2751
2752 assertShiftConstEquals(r, a, ByteMaxVectorTests::LSHL_binary_const);
2753 }
2754
2755
2756
2757 @Test(dataProvider = "byteUnaryOpMaskProvider")
2758 static void LSHLByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2759 IntFunction<boolean[]> fm) {
2760 byte[] a = fa.apply(SPECIES.length());
2761 byte[] r = fr.apply(SPECIES.length());
2762 boolean[] mask = fm.apply(SPECIES.length());
2763 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2764
2765 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2766 for (int i = 0; i < a.length; i += SPECIES.length()) {
2767 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2768 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
2769 }
2770 }
2771
2772 assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::LSHL_binary_const);
2773 }
2774
2775
2776
2777 static byte ASHR_binary_const(byte a) {
2778 return (byte)((a >> CONST_SHIFT));
2779 }
2780
2781 @Test(dataProvider = "byteUnaryOpProvider")
2782 static void ASHRByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2783 byte[] a = fa.apply(SPECIES.length());
2784 byte[] r = fr.apply(SPECIES.length());
2785
2786 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2787 for (int i = 0; i < a.length; i += SPECIES.length()) {
2788 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2789 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
2790 }
2791 }
2792
2793 assertShiftConstEquals(r, a, ByteMaxVectorTests::ASHR_binary_const);
2794 }
2795
2796
2797
2798 @Test(dataProvider = "byteUnaryOpMaskProvider")
2799 static void ASHRByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2800 IntFunction<boolean[]> fm) {
2801 byte[] a = fa.apply(SPECIES.length());
2802 byte[] r = fr.apply(SPECIES.length());
2803 boolean[] mask = fm.apply(SPECIES.length());
2804 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2805
2806 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2807 for (int i = 0; i < a.length; i += SPECIES.length()) {
2808 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2809 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
2810 }
2811 }
2812
2813 assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ASHR_binary_const);
2814 }
2815
2816
2817
2818 static byte ROR_binary_const(byte a) {
2819 return (byte)(ROR_scalar(a, CONST_SHIFT));
2820 }
2821
2822 @Test(dataProvider = "byteUnaryOpProvider")
2823 static void RORByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2824 byte[] a = fa.apply(SPECIES.length());
2825 byte[] r = fr.apply(SPECIES.length());
2826
2827 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2828 for (int i = 0; i < a.length; i += SPECIES.length()) {
2829 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2830 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
2831 }
2832 }
2833
2834 assertShiftConstEquals(r, a, ByteMaxVectorTests::ROR_binary_const);
2835 }
2836
2837
2838
2839 @Test(dataProvider = "byteUnaryOpMaskProvider")
2840 static void RORByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2841 IntFunction<boolean[]> fm) {
2842 byte[] a = fa.apply(SPECIES.length());
2843 byte[] r = fr.apply(SPECIES.length());
2844 boolean[] mask = fm.apply(SPECIES.length());
2845 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2846
2847 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2848 for (int i = 0; i < a.length; i += SPECIES.length()) {
2849 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2850 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
2851 }
2852 }
2853
2854 assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ROR_binary_const);
2855 }
2856
2857
2858
2859 static byte ROL_binary_const(byte a) {
2860 return (byte)(ROL_scalar(a, CONST_SHIFT));
2861 }
2862
2863 @Test(dataProvider = "byteUnaryOpProvider")
2864 static void ROLByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2865 byte[] a = fa.apply(SPECIES.length());
2866 byte[] r = fr.apply(SPECIES.length());
2867
2868 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2869 for (int i = 0; i < a.length; i += SPECIES.length()) {
2870 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2871 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
2872 }
2873 }
2874
2875 assertShiftConstEquals(r, a, ByteMaxVectorTests::ROL_binary_const);
2876 }
2877
2878
2879
2880 @Test(dataProvider = "byteUnaryOpMaskProvider")
2881 static void ROLByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2882 IntFunction<boolean[]> fm) {
2883 byte[] a = fa.apply(SPECIES.length());
2884 byte[] r = fr.apply(SPECIES.length());
2885 boolean[] mask = fm.apply(SPECIES.length());
2886 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2887
2888 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2889 for (int i = 0; i < a.length; i += SPECIES.length()) {
2890 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2891 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
2892 }
2893 }
2894
2895 assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ROL_binary_const);
2896 }
2897
2898
2899 static byte MIN(byte a, byte b) {
2900 return (byte)(Math.min(a, b));
2901 }
2902
2903 @Test(dataProvider = "byteBinaryOpProvider")
2904 static void MINByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2905 byte[] a = fa.apply(SPECIES.length());
2906 byte[] b = fb.apply(SPECIES.length());
2907 byte[] r = fr.apply(SPECIES.length());
2908
2909 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2910 for (int i = 0; i < a.length; i += SPECIES.length()) {
2911 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2912 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2913 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2914 }
2915 }
2916
2917 assertArraysEquals(r, a, b, ByteMaxVectorTests::MIN);
2918 }
2919 static byte min(byte a, byte b) {
2920 return (byte)(Math.min(a, b));
2921 }
2922
2923 @Test(dataProvider = "byteBinaryOpProvider")
2924 static void minByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2925 byte[] a = fa.apply(SPECIES.length());
2926 byte[] b = fb.apply(SPECIES.length());
2927 byte[] r = fr.apply(SPECIES.length());
2928
2929 for (int i = 0; i < a.length; i += SPECIES.length()) {
2930 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2931 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2932 av.min(bv).intoArray(r, i);
2933 }
2934
2935 assertArraysEquals(r, a, b, ByteMaxVectorTests::min);
2936 }
2937 static byte MAX(byte a, byte b) {
2938 return (byte)(Math.max(a, b));
2939 }
2940
2941 @Test(dataProvider = "byteBinaryOpProvider")
2942 static void MAXByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2943 byte[] a = fa.apply(SPECIES.length());
2944 byte[] b = fb.apply(SPECIES.length());
2945 byte[] r = fr.apply(SPECIES.length());
2946
2947 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2948 for (int i = 0; i < a.length; i += SPECIES.length()) {
2949 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2950 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2951 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2952 }
2953 }
2954
2955 assertArraysEquals(r, a, b, ByteMaxVectorTests::MAX);
2956 }
2957 static byte max(byte a, byte b) {
2958 return (byte)(Math.max(a, b));
2959 }
2960
2961 @Test(dataProvider = "byteBinaryOpProvider")
2962 static void maxByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2963 byte[] a = fa.apply(SPECIES.length());
2964 byte[] b = fb.apply(SPECIES.length());
2965 byte[] r = fr.apply(SPECIES.length());
2966
2967 for (int i = 0; i < a.length; i += SPECIES.length()) {
2968 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2969 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2970 av.max(bv).intoArray(r, i);
2971 }
2972
2973 assertArraysEquals(r, a, b, ByteMaxVectorTests::max);
2974 }
2975
2976 @Test(dataProvider = "byteBinaryOpProvider")
3030 }
3031
3032 static byte ANDReduce(byte[] a, int idx) {
3033 byte res = -1;
3034 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3035 res &= a[i];
3036 }
3037
3038 return res;
3039 }
3040
3041 static byte ANDReduceAll(byte[] a) {
3042 byte res = -1;
3043 for (int i = 0; i < a.length; i += SPECIES.length()) {
3044 res &= ANDReduce(a, i);
3045 }
3046
3047 return res;
3048 }
3049
3050
3051 @Test(dataProvider = "byteUnaryOpProvider")
3052 static void ANDReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3053 byte[] a = fa.apply(SPECIES.length());
3054 byte[] r = fr.apply(SPECIES.length());
3055 byte ra = -1;
3056
3057 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3058 for (int i = 0; i < a.length; i += SPECIES.length()) {
3059 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3060 r[i] = av.reduceLanes(VectorOperators.AND);
3061 }
3062 }
3063
3064 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3065 ra = -1;
3066 for (int i = 0; i < a.length; i += SPECIES.length()) {
3067 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3068 ra &= av.reduceLanes(VectorOperators.AND);
3069 }
3070 }
3071
3072 assertReductionArraysEquals(r, ra, a,
3073 ByteMaxVectorTests::ANDReduce, ByteMaxVectorTests::ANDReduceAll);
3074 }
3075
3076
3077 static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) {
3078 byte res = -1;
3079 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3080 if (mask[i % SPECIES.length()])
3081 res &= a[i];
3082 }
3083
3084 return res;
3085 }
3086
3087 static byte ANDReduceAllMasked(byte[] a, boolean[] mask) {
3088 byte res = -1;
3089 for (int i = 0; i < a.length; i += SPECIES.length()) {
3090 res &= ANDReduceMasked(a, i, mask);
3091 }
3092
3093 return res;
3094 }
3095
3096
3097 @Test(dataProvider = "byteUnaryOpMaskProvider")
3098 static void ANDReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3099 byte[] a = fa.apply(SPECIES.length());
3100 byte[] r = fr.apply(SPECIES.length());
3101 boolean[] mask = fm.apply(SPECIES.length());
3102 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3103 byte ra = -1;
3104
3105 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3106 for (int i = 0; i < a.length; i += SPECIES.length()) {
3107 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3108 r[i] = av.reduceLanes(VectorOperators.AND, vmask);
3109 }
3110 }
3111
3112 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3113 ra = -1;
3114 for (int i = 0; i < a.length; i += SPECIES.length()) {
3115 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3116 ra &= av.reduceLanes(VectorOperators.AND, vmask);
3117 }
3118 }
3119
3120 assertReductionArraysEqualsMasked(r, ra, a, mask,
3121 ByteMaxVectorTests::ANDReduceMasked, ByteMaxVectorTests::ANDReduceAllMasked);
3122 }
3123
3124
3125 static byte ORReduce(byte[] a, int idx) {
3126 byte res = 0;
3127 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3128 res |= a[i];
3129 }
3130
3131 return res;
3132 }
3133
3134 static byte ORReduceAll(byte[] a) {
3135 byte res = 0;
3136 for (int i = 0; i < a.length; i += SPECIES.length()) {
3137 res |= ORReduce(a, i);
3138 }
3139
3140 return res;
3141 }
3142
3143
3144 @Test(dataProvider = "byteUnaryOpProvider")
3145 static void ORReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3146 byte[] a = fa.apply(SPECIES.length());
3147 byte[] r = fr.apply(SPECIES.length());
3148 byte ra = 0;
3149
3150 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3151 for (int i = 0; i < a.length; i += SPECIES.length()) {
3152 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3153 r[i] = av.reduceLanes(VectorOperators.OR);
3154 }
3155 }
3156
3157 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3158 ra = 0;
3159 for (int i = 0; i < a.length; i += SPECIES.length()) {
3160 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3161 ra |= av.reduceLanes(VectorOperators.OR);
3162 }
3163 }
3164
3165 assertReductionArraysEquals(r, ra, a,
3166 ByteMaxVectorTests::ORReduce, ByteMaxVectorTests::ORReduceAll);
3167 }
3168
3169
3170 static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) {
3171 byte res = 0;
3172 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3173 if (mask[i % SPECIES.length()])
3174 res |= a[i];
3175 }
3176
3177 return res;
3178 }
3179
3180 static byte ORReduceAllMasked(byte[] a, boolean[] mask) {
3181 byte res = 0;
3182 for (int i = 0; i < a.length; i += SPECIES.length()) {
3183 res |= ORReduceMasked(a, i, mask);
3184 }
3185
3186 return res;
3187 }
3188
3189
3190 @Test(dataProvider = "byteUnaryOpMaskProvider")
3191 static void ORReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3192 byte[] a = fa.apply(SPECIES.length());
3193 byte[] r = fr.apply(SPECIES.length());
3194 boolean[] mask = fm.apply(SPECIES.length());
3195 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3196 byte ra = 0;
3197
3198 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3199 for (int i = 0; i < a.length; i += SPECIES.length()) {
3200 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3201 r[i] = av.reduceLanes(VectorOperators.OR, vmask);
3202 }
3203 }
3204
3205 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3206 ra = 0;
3207 for (int i = 0; i < a.length; i += SPECIES.length()) {
3208 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3209 ra |= av.reduceLanes(VectorOperators.OR, vmask);
3210 }
3211 }
3212
3213 assertReductionArraysEqualsMasked(r, ra, a, mask,
3214 ByteMaxVectorTests::ORReduceMasked, ByteMaxVectorTests::ORReduceAllMasked);
3215 }
3216
3217
3218 static byte XORReduce(byte[] a, int idx) {
3219 byte res = 0;
3220 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3221 res ^= a[i];
3222 }
3223
3224 return res;
3225 }
3226
3227 static byte XORReduceAll(byte[] a) {
3228 byte res = 0;
3229 for (int i = 0; i < a.length; i += SPECIES.length()) {
3230 res ^= XORReduce(a, i);
3231 }
3232
3233 return res;
3234 }
3235
3236
3237 @Test(dataProvider = "byteUnaryOpProvider")
3238 static void XORReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3239 byte[] a = fa.apply(SPECIES.length());
3240 byte[] r = fr.apply(SPECIES.length());
3241 byte ra = 0;
3242
3243 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3244 for (int i = 0; i < a.length; i += SPECIES.length()) {
3245 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3246 r[i] = av.reduceLanes(VectorOperators.XOR);
3247 }
3248 }
3249
3250 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3251 ra = 0;
3252 for (int i = 0; i < a.length; i += SPECIES.length()) {
3253 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3254 ra ^= av.reduceLanes(VectorOperators.XOR);
3255 }
3256 }
3257
3258 assertReductionArraysEquals(r, ra, a,
3259 ByteMaxVectorTests::XORReduce, ByteMaxVectorTests::XORReduceAll);
3260 }
3261
3262
3263 static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) {
3264 byte res = 0;
3265 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3266 if (mask[i % SPECIES.length()])
3267 res ^= a[i];
3268 }
3269
3270 return res;
3271 }
3272
3273 static byte XORReduceAllMasked(byte[] a, boolean[] mask) {
3274 byte res = 0;
3275 for (int i = 0; i < a.length; i += SPECIES.length()) {
3276 res ^= XORReduceMasked(a, i, mask);
3277 }
3278
3279 return res;
3280 }
3281
3282
3283 @Test(dataProvider = "byteUnaryOpMaskProvider")
3284 static void XORReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3285 byte[] a = fa.apply(SPECIES.length());
3286 byte[] r = fr.apply(SPECIES.length());
3287 boolean[] mask = fm.apply(SPECIES.length());
3288 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3289 byte ra = 0;
3290
3291 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3292 for (int i = 0; i < a.length; i += SPECIES.length()) {
3293 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3294 r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
3295 }
3296 }
3297
3298 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3299 ra = 0;
3300 for (int i = 0; i < a.length; i += SPECIES.length()) {
3301 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3302 ra ^= av.reduceLanes(VectorOperators.XOR, vmask);
3307 ByteMaxVectorTests::XORReduceMasked, ByteMaxVectorTests::XORReduceAllMasked);
3308 }
3309
3310 static byte ADDReduce(byte[] a, int idx) {
3311 byte res = 0;
3312 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3313 res += a[i];
3314 }
3315
3316 return res;
3317 }
3318
3319 static byte ADDReduceAll(byte[] a) {
3320 byte res = 0;
3321 for (int i = 0; i < a.length; i += SPECIES.length()) {
3322 res += ADDReduce(a, i);
3323 }
3324
3325 return res;
3326 }
3327 @Test(dataProvider = "byteUnaryOpProvider")
3328 static void ADDReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3329 byte[] a = fa.apply(SPECIES.length());
3330 byte[] r = fr.apply(SPECIES.length());
3331 byte ra = 0;
3332
3333 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3334 for (int i = 0; i < a.length; i += SPECIES.length()) {
3335 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3336 r[i] = av.reduceLanes(VectorOperators.ADD);
3337 }
3338 }
3339
3340 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3341 ra = 0;
3342 for (int i = 0; i < a.length; i += SPECIES.length()) {
3343 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3344 ra += av.reduceLanes(VectorOperators.ADD);
3345 }
3346 }
3347
3348 assertReductionArraysEquals(r, ra, a,
3349 ByteMaxVectorTests::ADDReduce, ByteMaxVectorTests::ADDReduceAll);
3350 }
3351 static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) {
3352 byte res = 0;
3353 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3354 if (mask[i % SPECIES.length()])
3355 res += a[i];
3356 }
3357
3358 return res;
3359 }
3360
3361 static byte ADDReduceAllMasked(byte[] a, boolean[] mask) {
3362 byte res = 0;
3363 for (int i = 0; i < a.length; i += SPECIES.length()) {
3364 res += ADDReduceMasked(a, i, mask);
3365 }
3366
3367 return res;
3368 }
3369 @Test(dataProvider = "byteUnaryOpMaskProvider")
3370 static void ADDReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3371 byte[] a = fa.apply(SPECIES.length());
3372 byte[] r = fr.apply(SPECIES.length());
3373 boolean[] mask = fm.apply(SPECIES.length());
3374 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3375 byte ra = 0;
3376
3377 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3378 for (int i = 0; i < a.length; i += SPECIES.length()) {
3379 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3380 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3381 }
3382 }
3383
3384 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3385 ra = 0;
3386 for (int i = 0; i < a.length; i += SPECIES.length()) {
3387 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3388 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3389 }
3390 }
3391
3392 assertReductionArraysEqualsMasked(r, ra, a, mask,
3393 ByteMaxVectorTests::ADDReduceMasked, ByteMaxVectorTests::ADDReduceAllMasked);
3394 }
3395 static byte MULReduce(byte[] a, int idx) {
3396 byte res = 1;
3397 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3398 res *= a[i];
3399 }
3400
3401 return res;
3402 }
3403
3404 static byte MULReduceAll(byte[] a) {
3405 byte res = 1;
3406 for (int i = 0; i < a.length; i += SPECIES.length()) {
3407 res *= MULReduce(a, i);
3408 }
3409
3410 return res;
3411 }
3412 @Test(dataProvider = "byteUnaryOpProvider")
3413 static void MULReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3414 byte[] a = fa.apply(SPECIES.length());
3415 byte[] r = fr.apply(SPECIES.length());
3416 byte ra = 1;
3417
3418 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3419 for (int i = 0; i < a.length; i += SPECIES.length()) {
3420 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3421 r[i] = av.reduceLanes(VectorOperators.MUL);
3422 }
3423 }
3424
3425 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3426 ra = 1;
3427 for (int i = 0; i < a.length; i += SPECIES.length()) {
3428 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3429 ra *= av.reduceLanes(VectorOperators.MUL);
3430 }
3431 }
3432
3433 assertReductionArraysEquals(r, ra, a,
3434 ByteMaxVectorTests::MULReduce, ByteMaxVectorTests::MULReduceAll);
3435 }
3436 static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) {
3437 byte res = 1;
3438 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3439 if (mask[i % SPECIES.length()])
3440 res *= a[i];
3441 }
3442
3443 return res;
3444 }
3445
3446 static byte MULReduceAllMasked(byte[] a, boolean[] mask) {
3447 byte res = 1;
3448 for (int i = 0; i < a.length; i += SPECIES.length()) {
3449 res *= MULReduceMasked(a, i, mask);
3450 }
3451
3452 return res;
3453 }
3454 @Test(dataProvider = "byteUnaryOpMaskProvider")
3455 static void MULReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3456 byte[] a = fa.apply(SPECIES.length());
3457 byte[] r = fr.apply(SPECIES.length());
3458 boolean[] mask = fm.apply(SPECIES.length());
3459 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3460 byte ra = 1;
3461
3462 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3463 for (int i = 0; i < a.length; i += SPECIES.length()) {
3464 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3465 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3466 }
3467 }
3468
3469 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3470 ra = 1;
3471 for (int i = 0; i < a.length; i += SPECIES.length()) {
3472 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3473 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
3474 }
3475 }
3476
3477 assertReductionArraysEqualsMasked(r, ra, a, mask,
3478 ByteMaxVectorTests::MULReduceMasked, ByteMaxVectorTests::MULReduceAllMasked);
3479 }
3480 static byte MINReduce(byte[] a, int idx) {
3481 byte res = Byte.MAX_VALUE;
3482 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3483 res = (byte) Math.min(res, a[i]);
3484 }
3485
3486 return res;
3487 }
3488
3489 static byte MINReduceAll(byte[] a) {
3490 byte res = Byte.MAX_VALUE;
3491 for (int i = 0; i < a.length; i += SPECIES.length()) {
3492 res = (byte) Math.min(res, MINReduce(a, i));
3493 }
3494
3495 return res;
3496 }
3497 @Test(dataProvider = "byteUnaryOpProvider")
3498 static void MINReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3499 byte[] a = fa.apply(SPECIES.length());
3500 byte[] r = fr.apply(SPECIES.length());
3501 byte ra = Byte.MAX_VALUE;
3502
3503 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3504 for (int i = 0; i < a.length; i += SPECIES.length()) {
3505 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3506 r[i] = av.reduceLanes(VectorOperators.MIN);
3507 }
3508 }
3509
3510 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3511 ra = Byte.MAX_VALUE;
3512 for (int i = 0; i < a.length; i += SPECIES.length()) {
3513 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3514 ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
3515 }
3516 }
3517
3518 assertReductionArraysEquals(r, ra, a,
3519 ByteMaxVectorTests::MINReduce, ByteMaxVectorTests::MINReduceAll);
3520 }
3521 static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) {
3522 byte res = Byte.MAX_VALUE;
3523 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3524 if (mask[i % SPECIES.length()])
3525 res = (byte) Math.min(res, a[i]);
3526 }
3527
3528 return res;
3529 }
3530
3531 static byte MINReduceAllMasked(byte[] a, boolean[] mask) {
3532 byte res = Byte.MAX_VALUE;
3533 for (int i = 0; i < a.length; i += SPECIES.length()) {
3534 res = (byte) Math.min(res, MINReduceMasked(a, i, mask));
3535 }
3536
3537 return res;
3538 }
3539 @Test(dataProvider = "byteUnaryOpMaskProvider")
3540 static void MINReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3541 byte[] a = fa.apply(SPECIES.length());
3542 byte[] r = fr.apply(SPECIES.length());
3543 boolean[] mask = fm.apply(SPECIES.length());
3544 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3545 byte ra = Byte.MAX_VALUE;
3546
3547 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3548 for (int i = 0; i < a.length; i += SPECIES.length()) {
3549 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3550 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
3551 }
3552 }
3553
3554 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3555 ra = Byte.MAX_VALUE;
3556 for (int i = 0; i < a.length; i += SPECIES.length()) {
3557 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3558 ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
3559 }
3560 }
3561
3562 assertReductionArraysEqualsMasked(r, ra, a, mask,
3563 ByteMaxVectorTests::MINReduceMasked, ByteMaxVectorTests::MINReduceAllMasked);
3564 }
3565 static byte MAXReduce(byte[] a, int idx) {
3566 byte res = Byte.MIN_VALUE;
3567 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3568 res = (byte) Math.max(res, a[i]);
3569 }
3570
3571 return res;
3572 }
3573
3574 static byte MAXReduceAll(byte[] a) {
3575 byte res = Byte.MIN_VALUE;
3576 for (int i = 0; i < a.length; i += SPECIES.length()) {
3577 res = (byte) Math.max(res, MAXReduce(a, i));
3578 }
3579
3580 return res;
3581 }
3582 @Test(dataProvider = "byteUnaryOpProvider")
3583 static void MAXReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3584 byte[] a = fa.apply(SPECIES.length());
3585 byte[] r = fr.apply(SPECIES.length());
3586 byte ra = Byte.MIN_VALUE;
3587
3588 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3589 for (int i = 0; i < a.length; i += SPECIES.length()) {
3590 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3591 r[i] = av.reduceLanes(VectorOperators.MAX);
3592 }
3593 }
3594
3595 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3596 ra = Byte.MIN_VALUE;
3597 for (int i = 0; i < a.length; i += SPECIES.length()) {
3598 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3599 ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
3600 }
3601 }
3602
3603 assertReductionArraysEquals(r, ra, a,
3604 ByteMaxVectorTests::MAXReduce, ByteMaxVectorTests::MAXReduceAll);
3605 }
3606 static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) {
3607 byte res = Byte.MIN_VALUE;
3608 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3609 if (mask[i % SPECIES.length()])
3610 res = (byte) Math.max(res, a[i]);
3611 }
3612
3613 return res;
3614 }
3615
3616 static byte MAXReduceAllMasked(byte[] a, boolean[] mask) {
3617 byte res = Byte.MIN_VALUE;
3618 for (int i = 0; i < a.length; i += SPECIES.length()) {
3619 res = (byte) Math.max(res, MAXReduceMasked(a, i, mask));
3620 }
3621
3622 return res;
3623 }
3624 @Test(dataProvider = "byteUnaryOpMaskProvider")
3625 static void MAXReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3626 byte[] a = fa.apply(SPECIES.length());
3627 byte[] r = fr.apply(SPECIES.length());
3628 boolean[] mask = fm.apply(SPECIES.length());
3629 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3630 byte ra = Byte.MIN_VALUE;
3631
3632 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3633 for (int i = 0; i < a.length; i += SPECIES.length()) {
3634 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3635 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
3636 }
3637 }
3638
3639 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3640 ra = Byte.MIN_VALUE;
3641 for (int i = 0; i < a.length; i += SPECIES.length()) {
3642 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3643 ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
3644 }
3645 }
3646
3647 assertReductionArraysEqualsMasked(r, ra, a, mask,
3648 ByteMaxVectorTests::MAXReduceMasked, ByteMaxVectorTests::MAXReduceAllMasked);
3649 }
3650 static byte FIRST_NONZEROReduce(byte[] a, int idx) {
3651 byte res = (byte) 0;
3652 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3653 res = firstNonZero(res, a[i]);
3654 }
3655
3656 return res;
3657 }
3658
3659 static byte FIRST_NONZEROReduceAll(byte[] a) {
3660 byte res = (byte) 0;
3661 for (int i = 0; i < a.length; i += SPECIES.length()) {
3662 res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
3663 }
3664
3665 return res;
3666 }
3667 @Test(dataProvider = "byteUnaryOpProvider")
3668 static void FIRST_NONZEROReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3669 byte[] a = fa.apply(SPECIES.length());
3670 byte[] r = fr.apply(SPECIES.length());
3671 byte ra = (byte) 0;
3672
3673 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3674 for (int i = 0; i < a.length; i += SPECIES.length()) {
3675 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3676 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
3677 }
3678 }
3679
3680 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3681 ra = (byte) 0;
3682 for (int i = 0; i < a.length; i += SPECIES.length()) {
3683 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3684 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
3685 }
3686 }
3687
3688 assertReductionArraysEquals(r, ra, a,
3689 ByteMaxVectorTests::FIRST_NONZEROReduce, ByteMaxVectorTests::FIRST_NONZEROReduceAll);
3690 }
3691 static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) {
3692 byte res = (byte) 0;
3693 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3694 if (mask[i % SPECIES.length()])
3695 res = firstNonZero(res, a[i]);
3696 }
3697
3698 return res;
3699 }
3700
3701 static byte FIRST_NONZEROReduceAllMasked(byte[] a, boolean[] mask) {
3702 byte res = (byte) 0;
3703 for (int i = 0; i < a.length; i += SPECIES.length()) {
3704 res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
3705 }
3706
3707 return res;
3708 }
3709 @Test(dataProvider = "byteUnaryOpMaskProvider")
3710 static void FIRST_NONZEROReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3711 byte[] a = fa.apply(SPECIES.length());
3712 byte[] r = fr.apply(SPECIES.length());
3713 boolean[] mask = fm.apply(SPECIES.length());
3714 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3715 byte ra = (byte) 0;
3716
3717 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3718 for (int i = 0; i < a.length; i += SPECIES.length()) {
3719 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3720 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
3721 }
3722 }
3723
3724 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3725 ra = (byte) 0;
3726 for (int i = 0; i < a.length; i += SPECIES.length()) {
3727 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3728 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
3729 }
3730 }
3731
3732 assertReductionArraysEqualsMasked(r, ra, a, mask,
3733 ByteMaxVectorTests::FIRST_NONZEROReduceMasked, ByteMaxVectorTests::FIRST_NONZEROReduceAllMasked);
3734 }
3735
3736 static boolean anyTrue(boolean[] a, int idx) {
3737 boolean res = false;
3738 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3739 res |= a[i];
3740 }
3741
3742 return res;
3743 }
3744
3745
3746 @Test(dataProvider = "boolUnaryOpProvider")
3747 static void anyTrueByteMaxVectorTests(IntFunction<boolean[]> fm) {
3748 boolean[] mask = fm.apply(SPECIES.length());
3749 boolean[] r = fmr.apply(SPECIES.length());
3750
3751 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3752 for (int i = 0; i < mask.length; i += SPECIES.length()) {
3753 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, i);
3754 r[i] = vmask.anyTrue();
3755 }
3756 }
3757
3758 assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::anyTrue);
3759 }
3760
3761
3762 static boolean allTrue(boolean[] a, int idx) {
3763 boolean res = true;
3764 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3765 res &= a[i];
3766 }
3767
3768 return res;
3769 }
3770
3771
3772 @Test(dataProvider = "boolUnaryOpProvider")
3773 static void allTrueByteMaxVectorTests(IntFunction<boolean[]> fm) {
3774 boolean[] mask = fm.apply(SPECIES.length());
3775 boolean[] r = fmr.apply(SPECIES.length());
3776
3777 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3778 for (int i = 0; i < mask.length; i += SPECIES.length()) {
3779 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, i);
3780 r[i] = vmask.allTrue();
3781 }
3782 }
3783
3784 assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::allTrue);
3785 }
3786
3787
3788 @Test(dataProvider = "byteUnaryOpProvider")
3789 static void withByteMaxVectorTests(IntFunction<byte []> fa) {
3790 byte[] a = fa.apply(SPECIES.length());
3791 byte[] r = fr.apply(SPECIES.length());
3792
3793 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3794 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3795 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3796 av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i);
3797 }
3798 }
3799
3800
3801 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3802 assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
3803 }
3804 }
3805 static boolean testIS_DEFAULT(byte a) {
3806 return bits(a)==0;
3807 }
3808
3809 @Test(dataProvider = "byteTestOpProvider")
3810 static void IS_DEFAULTByteMaxVectorTests(IntFunction<byte[]> fa) {
3811 byte[] a = fa.apply(SPECIES.length());
3812
3813 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3814 for (int i = 0; i < a.length; i += SPECIES.length()) {
3815 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3816 VectorMask<Byte> mv = av.test(VectorOperators.IS_DEFAULT);
3817
3818 // Check results as part of computation.
3819 for (int j = 0; j < SPECIES.length(); j++) {
3820 Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3821 }
3822 }
3823 }
3824 }
3825
3826 @Test(dataProvider = "byteTestOpMaskProvider")
3827 static void IS_DEFAULTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
3828 IntFunction<boolean[]> fm) {
3829 byte[] a = fa.apply(SPECIES.length());
3830 boolean[] mask = fm.apply(SPECIES.length());
3831 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3832
3833 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3834 for (int i = 0; i < a.length; i += SPECIES.length()) {
3835 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3836 VectorMask<Byte> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3837
3838 // Check results as part of computation.
3839 for (int j = 0; j < SPECIES.length(); j++) {
3840 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3841 }
3842 }
3843 }
3844 }
3845 static boolean testIS_NEGATIVE(byte a) {
3846 return bits(a)<0;
3847 }
3848
3849 @Test(dataProvider = "byteTestOpProvider")
3850 static void IS_NEGATIVEByteMaxVectorTests(IntFunction<byte[]> fa) {
3851 byte[] a = fa.apply(SPECIES.length());
3852
3853 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3854 for (int i = 0; i < a.length; i += SPECIES.length()) {
3855 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3856 VectorMask<Byte> mv = av.test(VectorOperators.IS_NEGATIVE);
3857
3858 // Check results as part of computation.
3859 for (int j = 0; j < SPECIES.length(); j++) {
3860 Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3861 }
3862 }
3863 }
3864 }
3866 @Test(dataProvider = "byteTestOpMaskProvider")
3867 static void IS_NEGATIVEMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
3868 IntFunction<boolean[]> fm) {
3869 byte[] a = fa.apply(SPECIES.length());
3870 boolean[] mask = fm.apply(SPECIES.length());
3871 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3872
3873 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3874 for (int i = 0; i < a.length; i += SPECIES.length()) {
3875 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3876 VectorMask<Byte> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3877
3878 // Check results as part of computation.
3879 for (int j = 0; j < SPECIES.length(); j++) {
3880 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3881 }
3882 }
3883 }
3884 }
3885
3886
3887
3888
3889 @Test(dataProvider = "byteCompareOpProvider")
3890 static void LTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3891 byte[] a = fa.apply(SPECIES.length());
3892 byte[] b = fb.apply(SPECIES.length());
3893
3894 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3895 for (int i = 0; i < a.length; i += SPECIES.length()) {
3896 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3897 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3898 VectorMask<Byte> mv = av.compare(VectorOperators.LT, bv);
3899
3900 // Check results as part of computation.
3901 for (int j = 0; j < SPECIES.length(); j++) {
3902 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3903 }
3904 }
3905 }
3906 }
3907
3908
3909 @Test(dataProvider = "byteCompareOpProvider")
3910 static void ltByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3911 byte[] a = fa.apply(SPECIES.length());
3912 byte[] b = fb.apply(SPECIES.length());
3913
3914 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3915 for (int i = 0; i < a.length; i += SPECIES.length()) {
3916 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3917 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3918 VectorMask<Byte> mv = av.lt(bv);
3919
3920 // Check results as part of computation.
3921 for (int j = 0; j < SPECIES.length(); j++) {
3922 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3923 }
3924 }
3925 }
3926 }
3927
3928 @Test(dataProvider = "byteCompareOpMaskProvider")
3931 byte[] a = fa.apply(SPECIES.length());
3932 byte[] b = fb.apply(SPECIES.length());
3933 boolean[] mask = fm.apply(SPECIES.length());
3934
3935 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3936
3937 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3938 for (int i = 0; i < a.length; i += SPECIES.length()) {
3939 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3940 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3941 VectorMask<Byte> mv = av.compare(VectorOperators.LT, bv, vmask);
3942
3943 // Check results as part of computation.
3944 for (int j = 0; j < SPECIES.length(); j++) {
3945 Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3946 }
3947 }
3948 }
3949 }
3950
3951
3952 @Test(dataProvider = "byteCompareOpProvider")
3953 static void GTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3954 byte[] a = fa.apply(SPECIES.length());
3955 byte[] b = fb.apply(SPECIES.length());
3956
3957 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3958 for (int i = 0; i < a.length; i += SPECIES.length()) {
3959 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3960 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3961 VectorMask<Byte> mv = av.compare(VectorOperators.GT, bv);
3962
3963 // Check results as part of computation.
3964 for (int j = 0; j < SPECIES.length(); j++) {
3965 Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3966 }
3967 }
3968 }
3969 }
3970
3971 @Test(dataProvider = "byteCompareOpMaskProvider")
3974 byte[] a = fa.apply(SPECIES.length());
3975 byte[] b = fb.apply(SPECIES.length());
3976 boolean[] mask = fm.apply(SPECIES.length());
3977
3978 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3979
3980 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3981 for (int i = 0; i < a.length; i += SPECIES.length()) {
3982 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3983 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3984 VectorMask<Byte> mv = av.compare(VectorOperators.GT, bv, vmask);
3985
3986 // Check results as part of computation.
3987 for (int j = 0; j < SPECIES.length(); j++) {
3988 Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
3989 }
3990 }
3991 }
3992 }
3993
3994
3995 @Test(dataProvider = "byteCompareOpProvider")
3996 static void EQByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3997 byte[] a = fa.apply(SPECIES.length());
3998 byte[] b = fb.apply(SPECIES.length());
3999
4000 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4001 for (int i = 0; i < a.length; i += SPECIES.length()) {
4002 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4003 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4004 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, bv);
4005
4006 // Check results as part of computation.
4007 for (int j = 0; j < SPECIES.length(); j++) {
4008 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4009 }
4010 }
4011 }
4012 }
4013
4014
4015 @Test(dataProvider = "byteCompareOpProvider")
4016 static void eqByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4017 byte[] a = fa.apply(SPECIES.length());
4018 byte[] b = fb.apply(SPECIES.length());
4019
4020 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4021 for (int i = 0; i < a.length; i += SPECIES.length()) {
4022 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4023 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4024 VectorMask<Byte> mv = av.eq(bv);
4025
4026 // Check results as part of computation.
4027 for (int j = 0; j < SPECIES.length(); j++) {
4028 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4029 }
4030 }
4031 }
4032 }
4033
4034 @Test(dataProvider = "byteCompareOpMaskProvider")
4037 byte[] a = fa.apply(SPECIES.length());
4038 byte[] b = fb.apply(SPECIES.length());
4039 boolean[] mask = fm.apply(SPECIES.length());
4040
4041 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4042
4043 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4044 for (int i = 0; i < a.length; i += SPECIES.length()) {
4045 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4046 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4047 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, bv, vmask);
4048
4049 // Check results as part of computation.
4050 for (int j = 0; j < SPECIES.length(); j++) {
4051 Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
4052 }
4053 }
4054 }
4055 }
4056
4057
4058 @Test(dataProvider = "byteCompareOpProvider")
4059 static void NEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4060 byte[] a = fa.apply(SPECIES.length());
4061 byte[] b = fb.apply(SPECIES.length());
4062
4063 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4064 for (int i = 0; i < a.length; i += SPECIES.length()) {
4065 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4066 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4067 VectorMask<Byte> mv = av.compare(VectorOperators.NE, bv);
4068
4069 // Check results as part of computation.
4070 for (int j = 0; j < SPECIES.length(); j++) {
4071 Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
4072 }
4073 }
4074 }
4075 }
4076
4077 @Test(dataProvider = "byteCompareOpMaskProvider")
4080 byte[] a = fa.apply(SPECIES.length());
4081 byte[] b = fb.apply(SPECIES.length());
4082 boolean[] mask = fm.apply(SPECIES.length());
4083
4084 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4085
4086 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4087 for (int i = 0; i < a.length; i += SPECIES.length()) {
4088 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4089 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4090 VectorMask<Byte> mv = av.compare(VectorOperators.NE, bv, vmask);
4091
4092 // Check results as part of computation.
4093 for (int j = 0; j < SPECIES.length(); j++) {
4094 Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
4095 }
4096 }
4097 }
4098 }
4099
4100
4101 @Test(dataProvider = "byteCompareOpProvider")
4102 static void LEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4103 byte[] a = fa.apply(SPECIES.length());
4104 byte[] b = fb.apply(SPECIES.length());
4105
4106 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4107 for (int i = 0; i < a.length; i += SPECIES.length()) {
4108 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4109 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4110 VectorMask<Byte> mv = av.compare(VectorOperators.LE, bv);
4111
4112 // Check results as part of computation.
4113 for (int j = 0; j < SPECIES.length(); j++) {
4114 Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
4115 }
4116 }
4117 }
4118 }
4119
4120 @Test(dataProvider = "byteCompareOpMaskProvider")
4123 byte[] a = fa.apply(SPECIES.length());
4124 byte[] b = fb.apply(SPECIES.length());
4125 boolean[] mask = fm.apply(SPECIES.length());
4126
4127 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4128
4129 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4130 for (int i = 0; i < a.length; i += SPECIES.length()) {
4131 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4132 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4133 VectorMask<Byte> mv = av.compare(VectorOperators.LE, bv, vmask);
4134
4135 // Check results as part of computation.
4136 for (int j = 0; j < SPECIES.length(); j++) {
4137 Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
4138 }
4139 }
4140 }
4141 }
4142
4143
4144 @Test(dataProvider = "byteCompareOpProvider")
4145 static void GEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4146 byte[] a = fa.apply(SPECIES.length());
4147 byte[] b = fb.apply(SPECIES.length());
4148
4149 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4150 for (int i = 0; i < a.length; i += SPECIES.length()) {
4151 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4152 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4153 VectorMask<Byte> mv = av.compare(VectorOperators.GE, bv);
4154
4155 // Check results as part of computation.
4156 for (int j = 0; j < SPECIES.length(); j++) {
4157 Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
4158 }
4159 }
4160 }
4161 }
4162
4163 @Test(dataProvider = "byteCompareOpMaskProvider")
4166 byte[] a = fa.apply(SPECIES.length());
4167 byte[] b = fb.apply(SPECIES.length());
4168 boolean[] mask = fm.apply(SPECIES.length());
4169
4170 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4171
4172 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4173 for (int i = 0; i < a.length; i += SPECIES.length()) {
4174 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4175 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4176 VectorMask<Byte> mv = av.compare(VectorOperators.GE, bv, vmask);
4177
4178 // Check results as part of computation.
4179 for (int j = 0; j < SPECIES.length(); j++) {
4180 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
4181 }
4182 }
4183 }
4184 }
4185
4186
4187
4188 @Test(dataProvider = "byteCompareOpProvider")
4189 static void UNSIGNED_LTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4190 byte[] a = fa.apply(SPECIES.length());
4191 byte[] b = fb.apply(SPECIES.length());
4192
4193 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4194 for (int i = 0; i < a.length; i += SPECIES.length()) {
4195 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4196 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4197 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
4198
4199 // Check results as part of computation.
4200 for (int j = 0; j < SPECIES.length(); j++) {
4201 Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
4202 }
4203 }
4204 }
4205 }
4206
4207
4208
4209 @Test(dataProvider = "byteCompareOpMaskProvider")
4210 static void UNSIGNED_LTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4211 IntFunction<boolean[]> fm) {
4212 byte[] a = fa.apply(SPECIES.length());
4213 byte[] b = fb.apply(SPECIES.length());
4214 boolean[] mask = fm.apply(SPECIES.length());
4215
4216 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4217
4218 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4219 for (int i = 0; i < a.length; i += SPECIES.length()) {
4220 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4221 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4222 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
4223
4224 // Check results as part of computation.
4225 for (int j = 0; j < SPECIES.length(); j++) {
4226 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
4227 }
4228 }
4229 }
4230 }
4231
4232
4233
4234
4235 @Test(dataProvider = "byteCompareOpProvider")
4236 static void UNSIGNED_GTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4237 byte[] a = fa.apply(SPECIES.length());
4238 byte[] b = fb.apply(SPECIES.length());
4239
4240 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4241 for (int i = 0; i < a.length; i += SPECIES.length()) {
4242 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4243 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4244 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
4245
4246 // Check results as part of computation.
4247 for (int j = 0; j < SPECIES.length(); j++) {
4248 Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
4249 }
4250 }
4251 }
4252 }
4253
4254
4255
4256 @Test(dataProvider = "byteCompareOpMaskProvider")
4257 static void UNSIGNED_GTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4258 IntFunction<boolean[]> fm) {
4259 byte[] a = fa.apply(SPECIES.length());
4260 byte[] b = fb.apply(SPECIES.length());
4261 boolean[] mask = fm.apply(SPECIES.length());
4262
4263 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4264
4265 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4266 for (int i = 0; i < a.length; i += SPECIES.length()) {
4267 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4268 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4269 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
4270
4271 // Check results as part of computation.
4272 for (int j = 0; j < SPECIES.length(); j++) {
4273 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
4274 }
4275 }
4276 }
4277 }
4278
4279
4280
4281
4282 @Test(dataProvider = "byteCompareOpProvider")
4283 static void UNSIGNED_LEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4284 byte[] a = fa.apply(SPECIES.length());
4285 byte[] b = fb.apply(SPECIES.length());
4286
4287 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4288 for (int i = 0; i < a.length; i += SPECIES.length()) {
4289 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4290 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4291 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
4292
4293 // Check results as part of computation.
4294 for (int j = 0; j < SPECIES.length(); j++) {
4295 Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
4296 }
4297 }
4298 }
4299 }
4300
4301
4302
4303 @Test(dataProvider = "byteCompareOpMaskProvider")
4304 static void UNSIGNED_LEByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4305 IntFunction<boolean[]> fm) {
4306 byte[] a = fa.apply(SPECIES.length());
4307 byte[] b = fb.apply(SPECIES.length());
4308 boolean[] mask = fm.apply(SPECIES.length());
4309
4310 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4311
4312 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4313 for (int i = 0; i < a.length; i += SPECIES.length()) {
4314 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4315 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4316 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
4317
4318 // Check results as part of computation.
4319 for (int j = 0; j < SPECIES.length(); j++) {
4320 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
4321 }
4322 }
4323 }
4324 }
4325
4326
4327
4328
4329 @Test(dataProvider = "byteCompareOpProvider")
4330 static void UNSIGNED_GEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4331 byte[] a = fa.apply(SPECIES.length());
4332 byte[] b = fb.apply(SPECIES.length());
4333
4334 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4335 for (int i = 0; i < a.length; i += SPECIES.length()) {
4336 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4337 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4338 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
4339
4340 // Check results as part of computation.
4341 for (int j = 0; j < SPECIES.length(); j++) {
4342 Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
4343 }
4344 }
4345 }
4346 }
4347
4348
4349
4350 @Test(dataProvider = "byteCompareOpMaskProvider")
4351 static void UNSIGNED_GEByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4352 IntFunction<boolean[]> fm) {
4353 byte[] a = fa.apply(SPECIES.length());
4354 byte[] b = fb.apply(SPECIES.length());
4355 boolean[] mask = fm.apply(SPECIES.length());
4356
4357 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4358
4359 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4360 for (int i = 0; i < a.length; i += SPECIES.length()) {
4361 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4362 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4363 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
4364
4365 // Check results as part of computation.
4366 for (int j = 0; j < SPECIES.length(); j++) {
4367 Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
4368 }
4369 }
4370 }
4371 }
4372
4373
4374
4375 @Test(dataProvider = "byteCompareOpProvider")
4376 static void LTByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4377 byte[] a = fa.apply(SPECIES.length());
4378 byte[] b = fb.apply(SPECIES.length());
4379
4380 for (int i = 0; i < a.length; i += SPECIES.length()) {
4381 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4382 VectorMask<Byte> mv = av.compare(VectorOperators.LT, b[i]);
4383
4384 // Check results as part of computation.
4385 for (int j = 0; j < SPECIES.length(); j++) {
4386 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4387 }
4388 }
4389 }
4390
4391
4392 @Test(dataProvider = "byteCompareOpMaskProvider")
4393 static void LTByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa,
4394 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
4395 byte[] a = fa.apply(SPECIES.length());
4396 byte[] b = fb.apply(SPECIES.length());
4397 boolean[] mask = fm.apply(SPECIES.length());
4398
4399 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4400
4401 for (int i = 0; i < a.length; i += SPECIES.length()) {
4402 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4403 VectorMask<Byte> mv = av.compare(VectorOperators.LT, b[i], vmask);
4404
4405 // Check results as part of computation.
4406 for (int j = 0; j < SPECIES.length(); j++) {
4407 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
4408 }
4409 }
4410 }
4411
4412 @Test(dataProvider = "byteCompareOpProvider")
4413 static void LTByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4414 byte[] a = fa.apply(SPECIES.length());
4415 byte[] b = fb.apply(SPECIES.length());
4416
4417 for (int i = 0; i < a.length; i += SPECIES.length()) {
4418 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4419 VectorMask<Byte> mv = av.compare(VectorOperators.LT, (long)b[i]);
4420
4421 // Check results as part of computation.
4422 for (int j = 0; j < SPECIES.length(); j++) {
4423 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i]));
4424 }
4425 }
4426 }
4427
4428
4429 @Test(dataProvider = "byteCompareOpMaskProvider")
4430 static void LTByteMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<byte[]> fa,
4431 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
4432 byte[] a = fa.apply(SPECIES.length());
4433 byte[] b = fb.apply(SPECIES.length());
4434 boolean[] mask = fm.apply(SPECIES.length());
4435
4436 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4437
4438 for (int i = 0; i < a.length; i += SPECIES.length()) {
4439 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4440 VectorMask<Byte> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
4441
4442 // Check results as part of computation.
4443 for (int j = 0; j < SPECIES.length(); j++) {
4444 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i])));
4445 }
4446 }
4447 }
4448
4449 @Test(dataProvider = "byteCompareOpProvider")
4450 static void EQByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4451 byte[] a = fa.apply(SPECIES.length());
4452 byte[] b = fb.apply(SPECIES.length());
4453
4454 for (int i = 0; i < a.length; i += SPECIES.length()) {
4455 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4456 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, b[i]);
4457
4458 // Check results as part of computation.
4459 for (int j = 0; j < SPECIES.length(); j++) {
4460 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4461 }
4462 }
4463 }
4464
4465
4466 @Test(dataProvider = "byteCompareOpMaskProvider")
4467 static void EQByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa,
4468 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
4469 byte[] a = fa.apply(SPECIES.length());
4470 byte[] b = fb.apply(SPECIES.length());
4471 boolean[] mask = fm.apply(SPECIES.length());
4472
4473 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4474
4475 for (int i = 0; i < a.length; i += SPECIES.length()) {
4476 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4477 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, b[i], vmask);
4478
4479 // Check results as part of computation.
4480 for (int j = 0; j < SPECIES.length(); j++) {
4481 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
4482 }
4483 }
4484 }
4485
4486 @Test(dataProvider = "byteCompareOpProvider")
4487 static void EQByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4488 byte[] a = fa.apply(SPECIES.length());
4489 byte[] b = fb.apply(SPECIES.length());
4490
4491 for (int i = 0; i < a.length; i += SPECIES.length()) {
4492 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4493 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, (long)b[i]);
4494
4495 // Check results as part of computation.
4496 for (int j = 0; j < SPECIES.length(); j++) {
4497 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i]));
4498 }
4499 }
4500 }
4501
4502
4503 @Test(dataProvider = "byteCompareOpMaskProvider")
4504 static void EQByteMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<byte[]> fa,
4505 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
4506 byte[] a = fa.apply(SPECIES.length());
4507 byte[] b = fb.apply(SPECIES.length());
4508 boolean[] mask = fm.apply(SPECIES.length());
4509
4510 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4511
4512 for (int i = 0; i < a.length; i += SPECIES.length()) {
4513 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4514 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
4515
4516 // Check results as part of computation.
4517 for (int j = 0; j < SPECIES.length(); j++) {
4518 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i])));
4519 }
4520 }
4521 }
4522
4561 assertRearrangeArraysEquals(r, a, order, SPECIES.length());
4562 }
4563
4564 @Test(dataProvider = "byteUnaryOpShuffleMaskProvider")
4565 static void RearrangeByteMaxVectorTestsMaskedSmokeTest(IntFunction<byte[]> fa,
4566 BiFunction<Integer,Integer,int[]> fs,
4567 IntFunction<boolean[]> fm) {
4568 byte[] a = fa.apply(SPECIES.length());
4569 int[] order = fs.apply(a.length, SPECIES.length());
4570 byte[] r = fr.apply(SPECIES.length());
4571 boolean[] mask = fm.apply(SPECIES.length());
4572 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4573
4574 for (int i = 0; i < a.length; i += SPECIES.length()) {
4575 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4576 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
4577 }
4578
4579 assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
4580 }
4581 @Test(dataProvider = "byteUnaryOpProvider")
4582 static void getByteMaxVectorTests(IntFunction<byte[]> fa) {
4583 byte[] a = fa.apply(SPECIES.length());
4584 byte[] r = fr.apply(SPECIES.length());
4585
4586 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4587 for (int i = 0; i < a.length; i += SPECIES.length()) {
4588 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4589 int num_lanes = SPECIES.length();
4590 // Manually unroll because full unroll happens after intrinsification.
4591 // Unroll is needed because get intrinsic requires for index to be a known constant.
4592 if (num_lanes == 1) {
4593 r[i]=av.lane(0);
4594 } else if (num_lanes == 2) {
4595 r[i]=av.lane(0);
4596 r[i+1]=av.lane(1);
4597 } else if (num_lanes == 4) {
4598 r[i]=av.lane(0);
4599 r[i+1]=av.lane(1);
4600 r[i+2]=av.lane(2);
4731 }
4732 }
4733
4734 assertArraysEquals(r, a, ByteMaxVectorTests::get);
4735 }
4736
4737 @Test(dataProvider = "byteUnaryOpProvider")
4738 static void BroadcastByteMaxVectorTests(IntFunction<byte[]> fa) {
4739 byte[] a = fa.apply(SPECIES.length());
4740 byte[] r = new byte[a.length];
4741
4742 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4743 for (int i = 0; i < a.length; i += SPECIES.length()) {
4744 ByteVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4745 }
4746 }
4747
4748 assertBroadcastArraysEquals(r, a);
4749 }
4750
4751
4752
4753
4754
4755 @Test(dataProvider = "byteUnaryOpProvider")
4756 static void ZeroByteMaxVectorTests(IntFunction<byte[]> fa) {
4757 byte[] a = fa.apply(SPECIES.length());
4758 byte[] r = new byte[a.length];
4759
4760 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4761 for (int i = 0; i < a.length; i += SPECIES.length()) {
4762 ByteVector.zero(SPECIES).intoArray(a, i);
4763 }
4764 }
4765
4766 Assert.assertEquals(a, r);
4767 }
4768
4769
4770
4771
4772 static byte[] sliceUnary(byte[] a, int origin, int idx) {
4773 byte[] res = new byte[SPECIES.length()];
4774 for (int i = 0; i < SPECIES.length(); i++){
4775 if(i+origin < SPECIES.length())
4776 res[i] = a[idx+i+origin];
4777 else
4778 res[i] = (byte)0;
4779 }
4780 return res;
4781 }
4782
4783 @Test(dataProvider = "byteUnaryOpProvider")
4784 static void sliceUnaryByteMaxVectorTests(IntFunction<byte[]> fa) {
4785 byte[] a = fa.apply(SPECIES.length());
4786 byte[] r = new byte[a.length];
4787 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4788 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4789 for (int i = 0; i < a.length; i += SPECIES.length()) {
4790 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4791 av.slice(origin).intoArray(r, i);
4792 }
4793 }
4794
4795 assertArraysEquals(r, a, origin, ByteMaxVectorTests::sliceUnary);
4796 }
4797 static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) {
4798 byte[] res = new byte[SPECIES.length()];
4799 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4800 if(i+origin < SPECIES.length())
4801 res[i] = a[idx+i+origin];
4802 else {
4803 res[i] = b[idx+j];
4804 j++;
4805 }
4806 }
4807 return res;
4808 }
4809
4810 @Test(dataProvider = "byteBinaryOpProvider")
4811 static void sliceBinaryByteMaxVectorTestsBinary(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4812 byte[] a = fa.apply(SPECIES.length());
4813 byte[] b = fb.apply(SPECIES.length());
4814 byte[] r = new byte[a.length];
4815 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4816 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4817 for (int i = 0; i < a.length; i += SPECIES.length()) {
4818 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4819 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4820 av.slice(origin, bv).intoArray(r, i);
4821 }
4822 }
4823
4824 assertArraysEquals(r, a, b, origin, ByteMaxVectorTests::sliceBinary);
4825 }
4826 static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) {
4827 byte[] res = new byte[SPECIES.length()];
4828 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4829 if(i+origin < SPECIES.length())
4830 res[i] = mask[i] ? a[idx+i+origin] : (byte)0;
4831 else {
4832 res[i] = mask[i] ? b[idx+j] : (byte)0;
4833 j++;
4834 }
4835 }
4836 return res;
4837 }
4838
4839 @Test(dataProvider = "byteBinaryOpMaskProvider")
4840 static void sliceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4841 IntFunction<boolean[]> fm) {
4842 byte[] a = fa.apply(SPECIES.length());
4843 byte[] b = fb.apply(SPECIES.length());
4844 boolean[] mask = fm.apply(SPECIES.length());
4845 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4846
4847 byte[] r = new byte[a.length];
4848 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4849 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4850 for (int i = 0; i < a.length; i += SPECIES.length()) {
4851 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4852 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4853 av.slice(origin, bv, vmask).intoArray(r, i);
4854 }
4855 }
4856
4857 assertArraysEquals(r, a, b, origin, mask, ByteMaxVectorTests::slice);
4858 }
4859 static byte[] unsliceUnary(byte[] a, int origin, int idx) {
4860 byte[] res = new byte[SPECIES.length()];
4861 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4862 if(i < origin)
4863 res[i] = (byte)0;
4864 else {
4865 res[i] = a[idx+j];
4866 j++;
4867 }
4868 }
4869 return res;
4870 }
4871
4872 @Test(dataProvider = "byteUnaryOpProvider")
4873 static void unsliceUnaryByteMaxVectorTests(IntFunction<byte[]> fa) {
4874 byte[] a = fa.apply(SPECIES.length());
4875 byte[] r = new byte[a.length];
4876 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4877 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4878 for (int i = 0; i < a.length; i += SPECIES.length()) {
4879 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4880 av.unslice(origin).intoArray(r, i);
4881 }
4882 }
4883
4884 assertArraysEquals(r, a, origin, ByteMaxVectorTests::unsliceUnary);
4885 }
4886 static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) {
4887 byte[] res = new byte[SPECIES.length()];
4888 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4889 if (part == 0) {
4890 if (i < origin)
4891 res[i] = b[idx+i];
4892 else {
4893 res[i] = a[idx+j];
4894 j++;
4895 }
4896 } else if (part == 1) {
4897 if (i < origin)
4898 res[i] = a[idx+SPECIES.length()-origin+i];
4899 else {
4900 res[i] = b[idx+origin+j];
4901 j++;
4902 }
4903 }
4904 }
4905 return res;
4906 }
4907
4908 @Test(dataProvider = "byteBinaryOpProvider")
4909 static void unsliceBinaryByteMaxVectorTestsBinary(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4910 byte[] a = fa.apply(SPECIES.length());
4911 byte[] b = fb.apply(SPECIES.length());
4912 byte[] r = new byte[a.length];
4913 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4914 int part = (new java.util.Random()).nextInt(2);
4915 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4916 for (int i = 0; i < a.length; i += SPECIES.length()) {
4917 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4918 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4919 av.unslice(origin, bv, part).intoArray(r, i);
4920 }
4921 }
4922
4923 assertArraysEquals(r, a, b, origin, part, ByteMaxVectorTests::unsliceBinary);
4924 }
4925 static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) {
4926 byte[] res = new byte[SPECIES.length()];
4927 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4928 if(i+origin < SPECIES.length())
4929 res[i] = b[idx+i+origin];
4930 else {
4931 res[i] = b[idx+j];
4932 j++;
4933 }
4934 }
4935 for (int i = 0; i < SPECIES.length(); i++){
4936 res[i] = mask[i] ? a[idx+i] : res[i];
4937 }
4938 byte[] res1 = new byte[SPECIES.length()];
4939 if (part == 0) {
4940 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4941 if (i < origin)
4942 res1[i] = b[idx+i];
4943 else {
4944 res1[i] = res[j];
4962 static void unsliceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4963 IntFunction<boolean[]> fm) {
4964 byte[] a = fa.apply(SPECIES.length());
4965 byte[] b = fb.apply(SPECIES.length());
4966 boolean[] mask = fm.apply(SPECIES.length());
4967 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4968 byte[] r = new byte[a.length];
4969 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4970 int part = (new java.util.Random()).nextInt(2);
4971 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4972 for (int i = 0; i < a.length; i += SPECIES.length()) {
4973 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4974 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4975 av.unslice(origin, bv, part, vmask).intoArray(r, i);
4976 }
4977 }
4978
4979 assertArraysEquals(r, a, b, origin, part, mask, ByteMaxVectorTests::unslice);
4980 }
4981
4982
4983
4984
4985
4986
4987
4988
4989
4990
4991
4992
4993
4994
4995
4996
4997
4998
4999
5000
5001
5002
5003
5004 static byte BITWISE_BLEND(byte a, byte b, byte c) {
5005 return (byte)((a&~(c))|(b&c));
5006 }
5007 static byte bitwiseBlend(byte a, byte b, byte c) {
5008 return (byte)((a&~(c))|(b&c));
5009 }
5010
5011
5012 @Test(dataProvider = "byteTernaryOpProvider")
5013 static void BITWISE_BLENDByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5014 byte[] a = fa.apply(SPECIES.length());
5015 byte[] b = fb.apply(SPECIES.length());
5016 byte[] c = fc.apply(SPECIES.length());
5017 byte[] r = fr.apply(SPECIES.length());
5018
5019 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5020 for (int i = 0; i < a.length; i += SPECIES.length()) {
5021 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5022 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5023 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5024 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
5025 }
5026 }
5027
5028 assertArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
5029 }
5030 @Test(dataProvider = "byteTernaryOpProvider")
5031 static void bitwiseBlendByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5032 byte[] a = fa.apply(SPECIES.length());
5033 byte[] b = fb.apply(SPECIES.length());
5034 byte[] c = fc.apply(SPECIES.length());
5035 byte[] r = fr.apply(SPECIES.length());
5036
5037 for (int i = 0; i < a.length; i += SPECIES.length()) {
5038 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5039 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5040 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5041 av.bitwiseBlend(bv, cv).intoArray(r, i);
5042 }
5043
5044 assertArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
5045 }
5046
5047
5048 @Test(dataProvider = "byteTernaryOpMaskProvider")
5049 static void BITWISE_BLENDByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5050 IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
5051 byte[] a = fa.apply(SPECIES.length());
5052 byte[] b = fb.apply(SPECIES.length());
5053 byte[] c = fc.apply(SPECIES.length());
5054 byte[] r = fr.apply(SPECIES.length());
5055 boolean[] mask = fm.apply(SPECIES.length());
5056 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5057
5058 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5059 for (int i = 0; i < a.length; i += SPECIES.length()) {
5060 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5061 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5062 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5063 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
5064 }
5065 }
5066
5067 assertArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5068 }
5069
5070
5071
5072
5073 @Test(dataProvider = "byteTernaryOpProvider")
5074 static void BITWISE_BLENDByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5075 byte[] a = fa.apply(SPECIES.length());
5076 byte[] b = fb.apply(SPECIES.length());
5077 byte[] c = fc.apply(SPECIES.length());
5078 byte[] r = fr.apply(SPECIES.length());
5079
5080 for (int i = 0; i < a.length; i += SPECIES.length()) {
5081 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5082 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5083 av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
5084 }
5085 assertBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
5086 }
5087
5088 @Test(dataProvider = "byteTernaryOpProvider")
5089 static void BITWISE_BLENDByteMaxVectorTestsAltBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5090 byte[] a = fa.apply(SPECIES.length());
5091 byte[] b = fb.apply(SPECIES.length());
5092 byte[] c = fc.apply(SPECIES.length());
5093 byte[] r = fr.apply(SPECIES.length());
5094
5095 for (int i = 0; i < a.length; i += SPECIES.length()) {
5096 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5097 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5098 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
5099 }
5100 assertAltBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
5101 }
5102 @Test(dataProvider = "byteTernaryOpProvider")
5103 static void bitwiseBlendByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5104 byte[] a = fa.apply(SPECIES.length());
5105 byte[] b = fb.apply(SPECIES.length());
5106 byte[] c = fc.apply(SPECIES.length());
5107 byte[] r = fr.apply(SPECIES.length());
5108
5109 for (int i = 0; i < a.length; i += SPECIES.length()) {
5110 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5111 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5112 av.bitwiseBlend(bv, c[i]).intoArray(r, i);
5113 }
5114 assertBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
5115 }
5116
5117 @Test(dataProvider = "byteTernaryOpProvider")
5118 static void bitwiseBlendByteMaxVectorTestsAltBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5119 byte[] a = fa.apply(SPECIES.length());
5120 byte[] b = fb.apply(SPECIES.length());
5121 byte[] c = fc.apply(SPECIES.length());
5122 byte[] r = fr.apply(SPECIES.length());
5123
5124 for (int i = 0; i < a.length; i += SPECIES.length()) {
5125 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5126 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5127 av.bitwiseBlend(b[i], cv).intoArray(r, i);
5128 }
5129 assertAltBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
5130 }
5131
5132
5133 @Test(dataProvider = "byteTernaryOpMaskProvider")
5134 static void BITWISE_BLENDByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5135 IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
5136 byte[] a = fa.apply(SPECIES.length());
5137 byte[] b = fb.apply(SPECIES.length());
5138 byte[] c = fc.apply(SPECIES.length());
5139 byte[] r = fr.apply(SPECIES.length());
5140 boolean[] mask = fm.apply(SPECIES.length());
5141 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5142
5143 for (int i = 0; i < a.length; i += SPECIES.length()) {
5144 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5145 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5146 av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
5147 }
5148
5149 assertBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5150 }
5151
5152 @Test(dataProvider = "byteTernaryOpMaskProvider")
5153 static void BITWISE_BLENDByteMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5154 IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
5155 byte[] a = fa.apply(SPECIES.length());
5156 byte[] b = fb.apply(SPECIES.length());
5157 byte[] c = fc.apply(SPECIES.length());
5158 byte[] r = fr.apply(SPECIES.length());
5159 boolean[] mask = fm.apply(SPECIES.length());
5160 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5161
5162 for (int i = 0; i < a.length; i += SPECIES.length()) {
5163 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5164 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5165 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
5166 }
5167
5168 assertAltBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5169 }
5170
5171
5172
5173
5174 @Test(dataProvider = "byteTernaryOpProvider")
5175 static void BITWISE_BLENDByteMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5176 byte[] a = fa.apply(SPECIES.length());
5177 byte[] b = fb.apply(SPECIES.length());
5178 byte[] c = fc.apply(SPECIES.length());
5179 byte[] r = fr.apply(SPECIES.length());
5180
5181 for (int i = 0; i < a.length; i += SPECIES.length()) {
5182 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5183 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
5184 }
5185
5186 assertDoubleBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
5187 }
5188 @Test(dataProvider = "byteTernaryOpProvider")
5189 static void bitwiseBlendByteMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5190 byte[] a = fa.apply(SPECIES.length());
5191 byte[] b = fb.apply(SPECIES.length());
5192 byte[] c = fc.apply(SPECIES.length());
5193 byte[] r = fr.apply(SPECIES.length());
5194
5195 for (int i = 0; i < a.length; i += SPECIES.length()) {
5196 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5197 av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
5198 }
5199
5200 assertDoubleBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
5201 }
5202
5203
5204 @Test(dataProvider = "byteTernaryOpMaskProvider")
5205 static void BITWISE_BLENDByteMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5206 IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
5207 byte[] a = fa.apply(SPECIES.length());
5208 byte[] b = fb.apply(SPECIES.length());
5209 byte[] c = fc.apply(SPECIES.length());
5210 byte[] r = fr.apply(SPECIES.length());
5211 boolean[] mask = fm.apply(SPECIES.length());
5212 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5213
5214 for (int i = 0; i < a.length; i += SPECIES.length()) {
5215 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5216 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
5217 }
5218
5219 assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5220 }
5221
5222
5223 static byte NEG(byte a) {
5224 return (byte)(-((byte)a));
5225 }
5226
5227 static byte neg(byte a) {
5228 return (byte)(-((byte)a));
5229 }
5230
5231 @Test(dataProvider = "byteUnaryOpProvider")
5232 static void NEGByteMaxVectorTests(IntFunction<byte[]> fa) {
5233 byte[] a = fa.apply(SPECIES.length());
5234 byte[] r = fr.apply(SPECIES.length());
5235
5236 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5237 for (int i = 0; i < a.length; i += SPECIES.length()) {
5238 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5239 av.lanewise(VectorOperators.NEG).intoArray(r, i);
5240 }
5241 }
5242
5315 }
5316
5317 @Test(dataProvider = "byteUnaryOpMaskProvider")
5318 static void ABSMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
5319 IntFunction<boolean[]> fm) {
5320 byte[] a = fa.apply(SPECIES.length());
5321 byte[] r = fr.apply(SPECIES.length());
5322 boolean[] mask = fm.apply(SPECIES.length());
5323 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5324
5325 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5326 for (int i = 0; i < a.length; i += SPECIES.length()) {
5327 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5328 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
5329 }
5330 }
5331
5332 assertArraysEquals(r, a, mask, ByteMaxVectorTests::ABS);
5333 }
5334
5335
5336 static byte NOT(byte a) {
5337 return (byte)(~((byte)a));
5338 }
5339
5340 static byte not(byte a) {
5341 return (byte)(~((byte)a));
5342 }
5343
5344
5345
5346 @Test(dataProvider = "byteUnaryOpProvider")
5347 static void NOTByteMaxVectorTests(IntFunction<byte[]> fa) {
5348 byte[] a = fa.apply(SPECIES.length());
5349 byte[] r = fr.apply(SPECIES.length());
5350
5351 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5352 for (int i = 0; i < a.length; i += SPECIES.length()) {
5353 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5354 av.lanewise(VectorOperators.NOT).intoArray(r, i);
5355 }
5356 }
5357
5358 assertArraysEquals(r, a, ByteMaxVectorTests::NOT);
5359 }
5360
5361 @Test(dataProvider = "byteUnaryOpProvider")
5362 static void notByteMaxVectorTests(IntFunction<byte[]> fa) {
5363 byte[] a = fa.apply(SPECIES.length());
5364 byte[] r = fr.apply(SPECIES.length());
5365
5366 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5367 for (int i = 0; i < a.length; i += SPECIES.length()) {
5368 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5369 av.not().intoArray(r, i);
5370 }
5371 }
5372
5373 assertArraysEquals(r, a, ByteMaxVectorTests::not);
5374 }
5375
5376
5377
5378 @Test(dataProvider = "byteUnaryOpMaskProvider")
5379 static void NOTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
5380 IntFunction<boolean[]> fm) {
5381 byte[] a = fa.apply(SPECIES.length());
5382 byte[] r = fr.apply(SPECIES.length());
5383 boolean[] mask = fm.apply(SPECIES.length());
5384 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5385
5386 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5387 for (int i = 0; i < a.length; i += SPECIES.length()) {
5388 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5389 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
5390 }
5391 }
5392
5393 assertArraysEquals(r, a, mask, ByteMaxVectorTests::NOT);
5394 }
5395
5396
5397
5398 static byte ZOMO(byte a) {
5399 return (byte)((a==0?0:-1));
5400 }
5401
5402
5403
5404 @Test(dataProvider = "byteUnaryOpProvider")
5405 static void ZOMOByteMaxVectorTests(IntFunction<byte[]> fa) {
5406 byte[] a = fa.apply(SPECIES.length());
5407 byte[] r = fr.apply(SPECIES.length());
5408
5409 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5410 for (int i = 0; i < a.length; i += SPECIES.length()) {
5411 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5412 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
5413 }
5414 }
5415
5416 assertArraysEquals(r, a, ByteMaxVectorTests::ZOMO);
5417 }
5418
5419
5420
5421 @Test(dataProvider = "byteUnaryOpMaskProvider")
5422 static void ZOMOMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
5423 IntFunction<boolean[]> fm) {
5424 byte[] a = fa.apply(SPECIES.length());
5425 byte[] r = fr.apply(SPECIES.length());
5426 boolean[] mask = fm.apply(SPECIES.length());
5427 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5428
5429 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5430 for (int i = 0; i < a.length; i += SPECIES.length()) {
5431 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5432 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
5433 }
5434 }
5435
5436 assertArraysEquals(r, a, mask, ByteMaxVectorTests::ZOMO);
5437 }
5438
5439
5440
5441
5442
5443 @Test(dataProvider = "byteCompareOpProvider")
5444 static void ltByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5445 byte[] a = fa.apply(SPECIES.length());
5446 byte[] b = fb.apply(SPECIES.length());
5447
5448 for (int i = 0; i < a.length; i += SPECIES.length()) {
5449 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5450 VectorMask<Byte> mv = av.lt(b[i]);
5451
5452 // Check results as part of computation.
5453 for (int j = 0; j < SPECIES.length(); j++) {
5454 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5455 }
5456 }
5457 }
5458
5459 @Test(dataProvider = "byteCompareOpProvider")
5460 static void eqByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5461 byte[] a = fa.apply(SPECIES.length());
5835 }
5836 }
5837 return i - idx;
5838 }
5839
5840 @Test(dataProvider = "maskProvider")
5841 static void maskFirstTrueByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5842 boolean[] a = fa.apply(SPECIES.length());
5843 int[] r = new int[a.length];
5844
5845 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5846 for (int i = 0; i < a.length; i += SPECIES.length()) {
5847 var vmask = SPECIES.loadMask(a, i);
5848 r[i] = vmask.firstTrue();
5849 }
5850 }
5851
5852 assertMaskReductionArraysEquals(r, a, ByteMaxVectorTests::maskFirstTrue);
5853 }
5854
5855
5856 @DataProvider
5857 public static Object[][] offsetProvider() {
5858 return new Object[][]{
5859 {0},
5860 {-1},
5861 {+1},
5862 {+2},
5863 {-2},
5864 };
5865 }
5866
5867 @Test(dataProvider = "offsetProvider")
5868 static void indexInRangeByteMaxVectorTestsSmokeTest(int offset) {
5869 int limit = SPECIES.length() * BUFFER_REPS;
5870 for (int i = 0; i < limit; i += SPECIES.length()) {
5871 var actualMask = SPECIES.indexInRange(i + offset, limit);
5872 var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5873 assert(actualMask.equals(expectedMask));
5874 for (int j = 0; j < SPECIES.length(); j++) {
5875 int index = i + j + offset;
5876 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5877 }
5878 }
5879 }
5880
5881 @DataProvider
5882 public static Object[][] lengthProvider() {
5883 return new Object[][]{
5884 {0},
5885 {1},
5886 {32},
5887 {37},
5888 {1024},
5889 {1024+1},
5890 {1024+5},
5891 };
5892 }
5893
5894 @Test(dataProvider = "lengthProvider")
5895 static void loopBoundByteMaxVectorTestsSmokeTest(int length) {
5896 int actualLoopBound = SPECIES.loopBound(length);
5897 int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5898 Assert.assertEquals(actualLoopBound, expectedLoopBound);
5899 }
5900
5901 @Test
5902 static void ElementSizeByteMaxVectorTestsSmokeTest() {
5903 ByteVector av = ByteVector.zero(SPECIES);
5904 int elsize = av.elementSize();
5905 Assert.assertEquals(elsize, Byte.SIZE);
5906 }
5907
5908 @Test
5909 static void VectorShapeByteMaxVectorTestsSmokeTest() {
5910 ByteVector av = ByteVector.zero(SPECIES);
5911 VectorShape vsh = av.shape();
5912 assert(vsh.equals(VectorShape.S_Max_BIT));
5913 }
5914
5915 @Test
5916 static void ShapeWithLanesByteMaxVectorTestsSmokeTest() {
5917 ByteVector av = ByteVector.zero(SPECIES);
5918 VectorShape vsh = av.shape();
5919 VectorSpecies species = vsh.withLanes(byte.class);
5920 assert(species.equals(SPECIES));
5943 ByteVector av = ByteVector.zero(SPECIES);
5944 VectorSpecies species = av.species().withLanes(byte.class);
5945 assert(species.equals(SPECIES));
5946 }
5947
5948 @Test
5949 static void WithShapeByteMaxVectorTestsSmokeTest() {
5950 ByteVector av = ByteVector.zero(SPECIES);
5951 VectorShape vsh = av.shape();
5952 VectorSpecies species = av.species().withShape(vsh);
5953 assert(species.equals(SPECIES));
5954 }
5955
5956 @Test
5957 static void MaskAllTrueByteMaxVectorTestsSmokeTest() {
5958 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5959 Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
5960 }
5961 }
5962 }
5963
|
249 } else {
250 Assert.assertEquals(r[i], a[i], "at index #" + i);
251 }
252 }
253 }
254
255 static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, int vector_len) {
256 int i = 0, j = 0;
257 try {
258 for (; i < a.length; i += vector_len) {
259 for (j = 0; j < vector_len; j++) {
260 Assert.assertEquals(r[i+j], a[i+order[i+j]]);
261 }
262 }
263 } catch (AssertionError e) {
264 int idx = i + j;
265 Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
266 }
267 }
268
269 static void assertcompressArraysEquals(byte[] r, byte[] a, boolean[] m, int vector_len) {
270 int i = 0, j = 0, k = 0;
271 try {
272 for (; i < a.length; i += vector_len) {
273 k = 0;
274 for (j = 0; j < vector_len; j++) {
275 if (m[(i + j) % SPECIES.length()]) {
276 Assert.assertEquals(r[i + k], a[i + j]);
277 k++;
278 }
279 }
280 for (; k < vector_len; k++) {
281 Assert.assertEquals(r[i + k], (byte)0);
282 }
283 }
284 } catch (AssertionError e) {
285 int idx = i + k;
286 if (m[(i + j) % SPECIES.length()]) {
287 Assert.assertEquals(r[idx], a[i + j], "at index #" + idx);
288 } else {
289 Assert.assertEquals(r[idx], (byte)0, "at index #" + idx);
290 }
291 }
292 }
293
294 static void assertexpandArraysEquals(byte[] r, byte[] a, boolean[] m, int vector_len) {
295 int i = 0, j = 0, k = 0;
296 try {
297 for (; i < a.length; i += vector_len) {
298 k = 0;
299 for (j = 0; j < vector_len; j++) {
300 if (m[(i + j) % SPECIES.length()]) {
301 Assert.assertEquals(r[i + j], a[i + k]);
302 k++;
303 } else {
304 Assert.assertEquals(r[i + j], (byte)0);
305 }
306 }
307 }
308 } catch (AssertionError e) {
309 int idx = i + j;
310 if (m[idx % SPECIES.length()]) {
311 Assert.assertEquals(r[idx], a[i + k], "at index #" + idx);
312 } else {
313 Assert.assertEquals(r[idx], (byte)0, "at index #" + idx);
314 }
315 }
316 }
317
318 static void assertSelectFromArraysEquals(byte[] r, byte[] a, byte[] order, int vector_len) {
319 int i = 0, j = 0;
320 try {
321 for (; i < a.length; i += vector_len) {
322 for (j = 0; j < vector_len; j++) {
323 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
324 }
325 }
326 } catch (AssertionError e) {
327 int idx = i + j;
328 Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
329 }
330 }
331
332 static void assertRearrangeArraysEquals(byte[] r, byte[] a, int[] order, boolean[] mask, int vector_len) {
333 int i = 0, j = 0;
334 try {
335 for (; i < a.length; i += vector_len) {
336 for (j = 0; j < vector_len; j++) {
337 if (mask[j % SPECIES.length()])
931 try {
932 for (; i < r.length; i++) {
933 Assert.assertEquals(r[i], (long)(a[i+offs]));
934 }
935 } catch (AssertionError e) {
936 Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
937 }
938 }
939
940 static void assertArraysEquals(double[] r, byte[] a, int offs) {
941 int i = 0;
942 try {
943 for (; i < r.length; i++) {
944 Assert.assertEquals(r[i], (double)(a[i+offs]));
945 }
946 } catch (AssertionError e) {
947 Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
948 }
949 }
950
951 static byte bits(byte e) {
952 return e;
953 }
954
955 static final List<IntFunction<byte[]>> BYTE_GENERATORS = List.of(
956 withToString("byte[-i * 5]", (int s) -> {
957 return fill(s * BUFFER_REPS,
958 i -> (byte)(-i * 5));
959 }),
960 withToString("byte[i * 5]", (int s) -> {
961 return fill(s * BUFFER_REPS,
962 i -> (byte)(i * 5));
963 }),
964 withToString("byte[i + 1]", (int s) -> {
965 return fill(s * BUFFER_REPS,
966 i -> (((byte)(i + 1) == 0) ? 1 : (byte)(i + 1)));
967 }),
968 withToString("byte[cornerCaseValue(i)]", (int s) -> {
969 return fill(s * BUFFER_REPS,
970 i -> cornerCaseValue(i));
1025 })).
1026 toArray(Object[][]::new);
1027 }
1028
1029 @DataProvider
1030 public Object[][] byteUnaryOpProvider() {
1031 return BYTE_GENERATORS.stream().
1032 map(f -> new Object[]{f}).
1033 toArray(Object[][]::new);
1034 }
1035
1036 @DataProvider
1037 public Object[][] byteUnaryOpMaskProvider() {
1038 return BOOLEAN_MASK_GENERATORS.stream().
1039 flatMap(fm -> BYTE_GENERATORS.stream().map(fa -> {
1040 return new Object[] {fa, fm};
1041 })).
1042 toArray(Object[][]::new);
1043 }
1044
1045 @DataProvider
1046 public Object[][] maskProvider() {
1047 return BOOLEAN_MASK_GENERATORS.stream().
1048 map(f -> new Object[]{f}).
1049 toArray(Object[][]::new);
1050 }
1051
1052 @DataProvider
1053 public Object[][] maskCompareOpProvider() {
1054 return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1055 toArray(Object[][]::new);
1056 }
1057
1058 @DataProvider
1059 public Object[][] shuffleProvider() {
1060 return INT_SHUFFLE_GENERATORS.stream().
1061 map(f -> new Object[]{f}).
1062 toArray(Object[][]::new);
1063 }
1064
1100
1101 @DataProvider
1102 public Object[][] byteUnaryOpSelectFromProvider() {
1103 return BYTE_SHUFFLE_GENERATORS.stream().
1104 flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
1105 return new Object[] {fa, fs};
1106 })).
1107 toArray(Object[][]::new);
1108 }
1109
1110 @DataProvider
1111 public Object[][] byteUnaryOpSelectFromMaskProvider() {
1112 return BOOLEAN_MASK_GENERATORS.stream().
1113 flatMap(fm -> BYTE_SHUFFLE_GENERATORS.stream().
1114 flatMap(fs -> BYTE_GENERATORS.stream().map(fa -> {
1115 return new Object[] {fa, fs, fm};
1116 }))).
1117 toArray(Object[][]::new);
1118 }
1119
1120 static final List<IntFunction<byte[]>> BYTE_COMPARE_GENERATORS = List.of(
1121 withToString("byte[i]", (int s) -> {
1122 return fill(s * BUFFER_REPS,
1123 i -> (byte)i);
1124 }),
1125 withToString("byte[i - length / 2]", (int s) -> {
1126 return fill(s * BUFFER_REPS,
1127 i -> (byte)(i - (s * BUFFER_REPS / 2)));
1128 }),
1129 withToString("byte[i + 1]", (int s) -> {
1130 return fill(s * BUFFER_REPS,
1131 i -> (byte)(i + 1));
1132 }),
1133 withToString("byte[i - 2]", (int s) -> {
1134 return fill(s * BUFFER_REPS,
1135 i -> (byte)(i - 2));
1136 }),
1137 withToString("byte[zigZag(i)]", (int s) -> {
1138 return fill(s * BUFFER_REPS,
1139 i -> i%3 == 0 ? (byte)i : (i%3 == 1 ? (byte)(i + 1) : (byte)(i - 2)));
1240 }
1241 }
1242 }
1243
1244 static void replaceZero(byte[] a, boolean[] mask, byte v) {
1245 for (int i = 0; i < a.length; i++) {
1246 if (mask[i % mask.length] && a[i] == 0) {
1247 a[i] = v;
1248 }
1249 }
1250 }
1251
1252 static byte ROL_scalar(byte a, byte b) {
1253 return (byte)(((((byte)a) & 0xFF) << (b & 7)) | ((((byte)a) & 0xFF) >>> (8 - (b & 7))));
1254 }
1255
1256 static byte ROR_scalar(byte a, byte b) {
1257 return (byte)(((((byte)a) & 0xFF) >>> (b & 7)) | ((((byte)a) & 0xFF) << (8 - (b & 7))));
1258 }
1259
1260 static byte TRAILING_ZEROS_COUNT_scalar(byte a) {
1261 return (byte) (a != 0 ? Integer.numberOfTrailingZeros(a) : 8);
1262 }
1263
1264 static byte LEADING_ZEROS_COUNT_scalar(byte a) {
1265 return (byte) (a >= 0 ? Integer.numberOfLeadingZeros(a) - 24 : 0);
1266 }
1267
1268 static byte REVERSE_scalar(byte a) {
1269 byte b = (byte) ROL_scalar(a, (byte) 4);
1270 b = (byte) (((b & 0x55) << 1) | ((b & 0xAA) >>> 1));
1271 b = (byte) (((b & 0x33) << 2) | ((b & 0xCC) >>> 2));
1272 return b;
1273 }
1274
1275 static boolean eq(byte a, byte b) {
1276 return a == b;
1277 }
1278
1279 static boolean neq(byte a, byte b) {
1280 return a != b;
1281 }
1282
1283 static boolean lt(byte a, byte b) {
1284 return a < b;
1285 }
1286
1287 static boolean le(byte a, byte b) {
1288 return a <= b;
1289 }
1290
1291 static boolean gt(byte a, byte b) {
1292 return a > b;
1293 }
1294
1404 @Test
1405 // Test div by 0.
1406 static void bitwiseDivByZeroSmokeTest() {
1407 try {
1408 ByteVector a = (ByteVector) SPECIES.broadcast(0).addIndex(1);
1409 ByteVector b = (ByteVector) SPECIES.broadcast(0);
1410 a.div(b);
1411 Assert.fail();
1412 } catch (ArithmeticException e) {
1413 }
1414
1415 try {
1416 ByteVector a = (ByteVector) SPECIES.broadcast(0).addIndex(1);
1417 ByteVector b = (ByteVector) SPECIES.broadcast(0);
1418 VectorMask<Byte> m = a.lt((byte) 1);
1419 a.div(b, m);
1420 Assert.fail();
1421 } catch (ArithmeticException e) {
1422 }
1423 }
1424
1425 static byte ADD(byte a, byte b) {
1426 return (byte)(a + b);
1427 }
1428
1429 @Test(dataProvider = "byteBinaryOpProvider")
1430 static void ADDByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1431 byte[] a = fa.apply(SPECIES.length());
1432 byte[] b = fb.apply(SPECIES.length());
1433 byte[] r = fr.apply(SPECIES.length());
1434
1435 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1436 for (int i = 0; i < a.length; i += SPECIES.length()) {
1437 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1438 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1439 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1440 }
1441 }
1442
1443 assertArraysEquals(r, a, b, ByteMaxVectorTests::ADD);
1444 }
1445
1446 static byte add(byte a, byte b) {
1447 return (byte)(a + b);
1448 }
1449
1450 @Test(dataProvider = "byteBinaryOpProvider")
1451 static void addByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1452 byte[] a = fa.apply(SPECIES.length());
1453 byte[] b = fb.apply(SPECIES.length());
1454 byte[] r = fr.apply(SPECIES.length());
1455
1456 for (int i = 0; i < a.length; i += SPECIES.length()) {
1457 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1458 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1459 av.add(bv).intoArray(r, i);
1460 }
1461
1462 assertArraysEquals(r, a, b, ByteMaxVectorTests::add);
1463 }
1464
1465 @Test(dataProvider = "byteBinaryOpMaskProvider")
1482 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ADD);
1483 }
1484
1485 @Test(dataProvider = "byteBinaryOpMaskProvider")
1486 static void addByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1487 IntFunction<boolean[]> fm) {
1488 byte[] a = fa.apply(SPECIES.length());
1489 byte[] b = fb.apply(SPECIES.length());
1490 byte[] r = fr.apply(SPECIES.length());
1491 boolean[] mask = fm.apply(SPECIES.length());
1492 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1493
1494 for (int i = 0; i < a.length; i += SPECIES.length()) {
1495 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1496 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1497 av.add(bv, vmask).intoArray(r, i);
1498 }
1499
1500 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::add);
1501 }
1502
1503 static byte SUB(byte a, byte b) {
1504 return (byte)(a - b);
1505 }
1506
1507 @Test(dataProvider = "byteBinaryOpProvider")
1508 static void SUBByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1509 byte[] a = fa.apply(SPECIES.length());
1510 byte[] b = fb.apply(SPECIES.length());
1511 byte[] r = fr.apply(SPECIES.length());
1512
1513 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1514 for (int i = 0; i < a.length; i += SPECIES.length()) {
1515 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1516 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1517 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1518 }
1519 }
1520
1521 assertArraysEquals(r, a, b, ByteMaxVectorTests::SUB);
1522 }
1523
1524 static byte sub(byte a, byte b) {
1525 return (byte)(a - b);
1526 }
1527
1528 @Test(dataProvider = "byteBinaryOpProvider")
1529 static void subByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1530 byte[] a = fa.apply(SPECIES.length());
1531 byte[] b = fb.apply(SPECIES.length());
1532 byte[] r = fr.apply(SPECIES.length());
1533
1534 for (int i = 0; i < a.length; i += SPECIES.length()) {
1535 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1536 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1537 av.sub(bv).intoArray(r, i);
1538 }
1539
1540 assertArraysEquals(r, a, b, ByteMaxVectorTests::sub);
1541 }
1542
1543 @Test(dataProvider = "byteBinaryOpMaskProvider")
1560 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SUB);
1561 }
1562
1563 @Test(dataProvider = "byteBinaryOpMaskProvider")
1564 static void subByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1565 IntFunction<boolean[]> fm) {
1566 byte[] a = fa.apply(SPECIES.length());
1567 byte[] b = fb.apply(SPECIES.length());
1568 byte[] r = fr.apply(SPECIES.length());
1569 boolean[] mask = fm.apply(SPECIES.length());
1570 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1571
1572 for (int i = 0; i < a.length; i += SPECIES.length()) {
1573 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1574 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1575 av.sub(bv, vmask).intoArray(r, i);
1576 }
1577
1578 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::sub);
1579 }
1580
1581 static byte MUL(byte a, byte b) {
1582 return (byte)(a * b);
1583 }
1584
1585 @Test(dataProvider = "byteBinaryOpProvider")
1586 static void MULByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1587 byte[] a = fa.apply(SPECIES.length());
1588 byte[] b = fb.apply(SPECIES.length());
1589 byte[] r = fr.apply(SPECIES.length());
1590
1591 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1592 for (int i = 0; i < a.length; i += SPECIES.length()) {
1593 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1594 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1595 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1596 }
1597 }
1598
1599 assertArraysEquals(r, a, b, ByteMaxVectorTests::MUL);
1600 }
1601
1602 static byte mul(byte a, byte b) {
1603 return (byte)(a * b);
1604 }
1605
1606 @Test(dataProvider = "byteBinaryOpProvider")
1607 static void mulByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1608 byte[] a = fa.apply(SPECIES.length());
1609 byte[] b = fb.apply(SPECIES.length());
1610 byte[] r = fr.apply(SPECIES.length());
1611
1612 for (int i = 0; i < a.length; i += SPECIES.length()) {
1613 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1614 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1615 av.mul(bv).intoArray(r, i);
1616 }
1617
1618 assertArraysEquals(r, a, b, ByteMaxVectorTests::mul);
1619 }
1620
1621 @Test(dataProvider = "byteBinaryOpMaskProvider")
1639 }
1640
1641 @Test(dataProvider = "byteBinaryOpMaskProvider")
1642 static void mulByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1643 IntFunction<boolean[]> fm) {
1644 byte[] a = fa.apply(SPECIES.length());
1645 byte[] b = fb.apply(SPECIES.length());
1646 byte[] r = fr.apply(SPECIES.length());
1647 boolean[] mask = fm.apply(SPECIES.length());
1648 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1649
1650 for (int i = 0; i < a.length; i += SPECIES.length()) {
1651 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1652 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1653 av.mul(bv, vmask).intoArray(r, i);
1654 }
1655
1656 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::mul);
1657 }
1658
1659 static byte DIV(byte a, byte b) {
1660 return (byte)(a / b);
1661 }
1662
1663 @Test(dataProvider = "byteBinaryOpProvider")
1664 static void DIVByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1665 byte[] a = fa.apply(SPECIES.length());
1666 byte[] b = fb.apply(SPECIES.length());
1667 byte[] r = fr.apply(SPECIES.length());
1668
1669 replaceZero(b, (byte) 1);
1670
1671 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1672 for (int i = 0; i < a.length; i += SPECIES.length()) {
1673 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1674 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1675 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1676 }
1677 }
1678
1679 assertArraysEquals(r, a, b, ByteMaxVectorTests::DIV);
1680 }
1681
1682 static byte div(byte a, byte b) {
1683 return (byte)(a / b);
1684 }
1685
1686 @Test(dataProvider = "byteBinaryOpProvider")
1687 static void divByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1688 byte[] a = fa.apply(SPECIES.length());
1689 byte[] b = fb.apply(SPECIES.length());
1690 byte[] r = fr.apply(SPECIES.length());
1691
1692 replaceZero(b, (byte) 1);
1693
1694 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1695 for (int i = 0; i < a.length; i += SPECIES.length()) {
1696 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1697 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1698 av.div(bv).intoArray(r, i);
1699 }
1700 }
1701
1702 assertArraysEquals(r, a, b, ByteMaxVectorTests::div);
1703 }
1704
1705 @Test(dataProvider = "byteBinaryOpMaskProvider")
1706 static void DIVByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1707 IntFunction<boolean[]> fm) {
1708 byte[] a = fa.apply(SPECIES.length());
1709 byte[] b = fb.apply(SPECIES.length());
1710 byte[] r = fr.apply(SPECIES.length());
1711 boolean[] mask = fm.apply(SPECIES.length());
1712 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1713
1714 replaceZero(b, mask, (byte) 1);
1715
1716 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1717 for (int i = 0; i < a.length; i += SPECIES.length()) {
1718 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1719 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1720 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1721 }
1722 }
1723
1724 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::DIV);
1790 static byte AND(byte a, byte b) {
1791 return (byte)(a & b);
1792 }
1793
1794 @Test(dataProvider = "byteBinaryOpProvider")
1795 static void ANDByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1796 byte[] a = fa.apply(SPECIES.length());
1797 byte[] b = fb.apply(SPECIES.length());
1798 byte[] r = fr.apply(SPECIES.length());
1799
1800 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1801 for (int i = 0; i < a.length; i += SPECIES.length()) {
1802 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1803 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1804 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1805 }
1806 }
1807
1808 assertArraysEquals(r, a, b, ByteMaxVectorTests::AND);
1809 }
1810
1811 static byte and(byte a, byte b) {
1812 return (byte)(a & b);
1813 }
1814
1815 @Test(dataProvider = "byteBinaryOpProvider")
1816 static void andByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1817 byte[] a = fa.apply(SPECIES.length());
1818 byte[] b = fb.apply(SPECIES.length());
1819 byte[] r = fr.apply(SPECIES.length());
1820
1821 for (int i = 0; i < a.length; i += SPECIES.length()) {
1822 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1823 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1824 av.and(bv).intoArray(r, i);
1825 }
1826
1827 assertArraysEquals(r, a, b, ByteMaxVectorTests::and);
1828 }
1829
1830 @Test(dataProvider = "byteBinaryOpMaskProvider")
1831 static void ANDByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1832 IntFunction<boolean[]> fm) {
1833 byte[] a = fa.apply(SPECIES.length());
1834 byte[] b = fb.apply(SPECIES.length());
1835 byte[] r = fr.apply(SPECIES.length());
1836 boolean[] mask = fm.apply(SPECIES.length());
1837 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1838
1839 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1840 for (int i = 0; i < a.length; i += SPECIES.length()) {
1841 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1842 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1843 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
1844 }
1845 }
1846
1847 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND);
1848 }
1849
1850 static byte AND_NOT(byte a, byte b) {
1851 return (byte)(a & ~b);
1852 }
1853
1854 @Test(dataProvider = "byteBinaryOpProvider")
1855 static void AND_NOTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1856 byte[] a = fa.apply(SPECIES.length());
1857 byte[] b = fb.apply(SPECIES.length());
1858 byte[] r = fr.apply(SPECIES.length());
1859
1860 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1861 for (int i = 0; i < a.length; i += SPECIES.length()) {
1862 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1863 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1864 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
1865 }
1866 }
1867
1868 assertArraysEquals(r, a, b, ByteMaxVectorTests::AND_NOT);
1869 }
1870
1871 @Test(dataProvider = "byteBinaryOpMaskProvider")
1872 static void AND_NOTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1873 IntFunction<boolean[]> fm) {
1874 byte[] a = fa.apply(SPECIES.length());
1875 byte[] b = fb.apply(SPECIES.length());
1876 byte[] r = fr.apply(SPECIES.length());
1877 boolean[] mask = fm.apply(SPECIES.length());
1878 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1879
1880 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1881 for (int i = 0; i < a.length; i += SPECIES.length()) {
1882 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1883 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1884 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
1885 }
1886 }
1887
1888 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND_NOT);
1889 }
1890
1891 static byte OR(byte a, byte b) {
1892 return (byte)(a | b);
1893 }
1894
1895 @Test(dataProvider = "byteBinaryOpProvider")
1896 static void ORByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1897 byte[] a = fa.apply(SPECIES.length());
1898 byte[] b = fb.apply(SPECIES.length());
1899 byte[] r = fr.apply(SPECIES.length());
1900
1901 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1902 for (int i = 0; i < a.length; i += SPECIES.length()) {
1903 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1904 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1905 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1906 }
1907 }
1908
1909 assertArraysEquals(r, a, b, ByteMaxVectorTests::OR);
1910 }
1911
1912 static byte or(byte a, byte b) {
1913 return (byte)(a | b);
1914 }
1915
1916 @Test(dataProvider = "byteBinaryOpProvider")
1917 static void orByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1918 byte[] a = fa.apply(SPECIES.length());
1919 byte[] b = fb.apply(SPECIES.length());
1920 byte[] r = fr.apply(SPECIES.length());
1921
1922 for (int i = 0; i < a.length; i += SPECIES.length()) {
1923 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1924 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1925 av.or(bv).intoArray(r, i);
1926 }
1927
1928 assertArraysEquals(r, a, b, ByteMaxVectorTests::or);
1929 }
1930
1931 @Test(dataProvider = "byteBinaryOpMaskProvider")
1932 static void ORByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1933 IntFunction<boolean[]> fm) {
1934 byte[] a = fa.apply(SPECIES.length());
1935 byte[] b = fb.apply(SPECIES.length());
1936 byte[] r = fr.apply(SPECIES.length());
1937 boolean[] mask = fm.apply(SPECIES.length());
1938 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1939
1940 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1941 for (int i = 0; i < a.length; i += SPECIES.length()) {
1942 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1943 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1944 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1945 }
1946 }
1947
1948 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR);
1949 }
1950
1951 static byte XOR(byte a, byte b) {
1952 return (byte)(a ^ b);
1953 }
1954
1955 @Test(dataProvider = "byteBinaryOpProvider")
1956 static void XORByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1957 byte[] a = fa.apply(SPECIES.length());
1958 byte[] b = fb.apply(SPECIES.length());
1959 byte[] r = fr.apply(SPECIES.length());
1960
1961 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1962 for (int i = 0; i < a.length; i += SPECIES.length()) {
1963 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1964 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1965 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
1966 }
1967 }
1968
1969 assertArraysEquals(r, a, b, ByteMaxVectorTests::XOR);
1970 }
1971
1972 @Test(dataProvider = "byteBinaryOpMaskProvider")
1973 static void XORByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
1974 IntFunction<boolean[]> fm) {
1975 byte[] a = fa.apply(SPECIES.length());
1976 byte[] b = fb.apply(SPECIES.length());
1977 byte[] r = fr.apply(SPECIES.length());
1978 boolean[] mask = fm.apply(SPECIES.length());
1979 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1980
1981 for (int ic = 0; ic < INVOC_COUNT; ic++) {
1982 for (int i = 0; i < a.length; i += SPECIES.length()) {
1983 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
1984 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
1985 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1986 }
1987 }
1988
1989 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::XOR);
1990 }
1991
1992 @Test(dataProvider = "byteBinaryOpProvider")
1993 static void addByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
1994 byte[] a = fa.apply(SPECIES.length());
1995 byte[] b = fb.apply(SPECIES.length());
1996 byte[] r = fr.apply(SPECIES.length());
1997
1998 for (int i = 0; i < a.length; i += SPECIES.length()) {
1999 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2000 av.add(b[i]).intoArray(r, i);
2001 }
2002
2003 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::add);
2004 }
2005
2006 @Test(dataProvider = "byteBinaryOpMaskProvider")
2007 static void addByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2008 IntFunction<boolean[]> fm) {
2009 byte[] a = fa.apply(SPECIES.length());
2010 byte[] b = fb.apply(SPECIES.length());
2011 byte[] r = fr.apply(SPECIES.length());
2065 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::mul);
2066 }
2067
2068 @Test(dataProvider = "byteBinaryOpMaskProvider")
2069 static void mulByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2070 IntFunction<boolean[]> fm) {
2071 byte[] a = fa.apply(SPECIES.length());
2072 byte[] b = fb.apply(SPECIES.length());
2073 byte[] r = fr.apply(SPECIES.length());
2074 boolean[] mask = fm.apply(SPECIES.length());
2075 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2076
2077 for (int i = 0; i < a.length; i += SPECIES.length()) {
2078 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2079 av.mul(b[i], vmask).intoArray(r, i);
2080 }
2081
2082 assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::mul);
2083 }
2084
2085 @Test(dataProvider = "byteBinaryOpProvider")
2086 static void divByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2087 byte[] a = fa.apply(SPECIES.length());
2088 byte[] b = fb.apply(SPECIES.length());
2089 byte[] r = fr.apply(SPECIES.length());
2090
2091 replaceZero(b, (byte) 1);
2092
2093 for (int i = 0; i < a.length; i += SPECIES.length()) {
2094 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2095 av.div(b[i]).intoArray(r, i);
2096 }
2097
2098 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::div);
2099 }
2100
2101 @Test(dataProvider = "byteBinaryOpMaskProvider")
2102 static void divByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2103 IntFunction<boolean[]> fm) {
2104 byte[] a = fa.apply(SPECIES.length());
2105 byte[] b = fb.apply(SPECIES.length());
2106 byte[] r = fr.apply(SPECIES.length());
2107 boolean[] mask = fm.apply(SPECIES.length());
2108 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2109
2110 replaceZero(b, (byte) 1);
2111
2112 for (int i = 0; i < a.length; i += SPECIES.length()) {
2113 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2114 av.div(b[i], vmask).intoArray(r, i);
2115 }
2116
2117 assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::div);
2118 }
2119
2120 @Test(dataProvider = "byteBinaryOpProvider")
2121 static void ORByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2122 byte[] a = fa.apply(SPECIES.length());
2123 byte[] b = fb.apply(SPECIES.length());
2124 byte[] r = fr.apply(SPECIES.length());
2125
2126 for (int i = 0; i < a.length; i += SPECIES.length()) {
2127 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2128 av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2129 }
2130
2131 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::OR);
2132 }
2133
2134 @Test(dataProvider = "byteBinaryOpProvider")
2135 static void orByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2136 byte[] a = fa.apply(SPECIES.length());
2137 byte[] b = fb.apply(SPECIES.length());
2138 byte[] r = fr.apply(SPECIES.length());
2139
2140 for (int i = 0; i < a.length; i += SPECIES.length()) {
2141 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2142 av.or(b[i]).intoArray(r, i);
2143 }
2144
2145 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::or);
2146 }
2147
2148 @Test(dataProvider = "byteBinaryOpMaskProvider")
2149 static void ORByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2150 IntFunction<boolean[]> fm) {
2151 byte[] a = fa.apply(SPECIES.length());
2152 byte[] b = fb.apply(SPECIES.length());
2153 byte[] r = fr.apply(SPECIES.length());
2154 boolean[] mask = fm.apply(SPECIES.length());
2155 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2156
2157 for (int i = 0; i < a.length; i += SPECIES.length()) {
2158 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2159 av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2160 }
2161
2162 assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR);
2163 }
2164
2165 @Test(dataProvider = "byteBinaryOpProvider")
2166 static void ANDByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2167 byte[] a = fa.apply(SPECIES.length());
2168 byte[] b = fb.apply(SPECIES.length());
2169 byte[] r = fr.apply(SPECIES.length());
2170
2171 for (int i = 0; i < a.length; i += SPECIES.length()) {
2172 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2173 av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2174 }
2175
2176 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::AND);
2177 }
2178
2179 @Test(dataProvider = "byteBinaryOpProvider")
2180 static void andByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2181 byte[] a = fa.apply(SPECIES.length());
2182 byte[] b = fb.apply(SPECIES.length());
2183 byte[] r = fr.apply(SPECIES.length());
2184
2185 for (int i = 0; i < a.length; i += SPECIES.length()) {
2186 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2187 av.and(b[i]).intoArray(r, i);
2188 }
2189
2190 assertBroadcastArraysEquals(r, a, b, ByteMaxVectorTests::and);
2191 }
2192
2193 @Test(dataProvider = "byteBinaryOpMaskProvider")
2194 static void ANDByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2195 IntFunction<boolean[]> fm) {
2196 byte[] a = fa.apply(SPECIES.length());
2197 byte[] b = fb.apply(SPECIES.length());
2198 byte[] r = fr.apply(SPECIES.length());
2199 boolean[] mask = fm.apply(SPECIES.length());
2200 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2201
2202 for (int i = 0; i < a.length; i += SPECIES.length()) {
2203 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2204 av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2205 }
2206
2207 assertBroadcastArraysEquals(r, a, b, mask, ByteMaxVectorTests::AND);
2208 }
2209
2210 @Test(dataProvider = "byteBinaryOpProvider")
2211 static void ORByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2212 byte[] a = fa.apply(SPECIES.length());
2213 byte[] b = fb.apply(SPECIES.length());
2214 byte[] r = fr.apply(SPECIES.length());
2215
2216 for (int i = 0; i < a.length; i += SPECIES.length()) {
2217 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2218 av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2219 }
2220
2221 assertBroadcastLongArraysEquals(r, a, b, ByteMaxVectorTests::OR);
2222 }
2223
2224 @Test(dataProvider = "byteBinaryOpMaskProvider")
2225 static void ORByteMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2226 IntFunction<boolean[]> fm) {
2227 byte[] a = fa.apply(SPECIES.length());
2228 byte[] b = fb.apply(SPECIES.length());
2229 byte[] r = fr.apply(SPECIES.length());
2230 boolean[] mask = fm.apply(SPECIES.length());
2231 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2232
2233 for (int i = 0; i < a.length; i += SPECIES.length()) {
2234 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2235 av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2236 }
2237
2238 assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::OR);
2239 }
2240
2241 @Test(dataProvider = "byteBinaryOpProvider")
2242 static void ADDByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2243 byte[] a = fa.apply(SPECIES.length());
2244 byte[] b = fb.apply(SPECIES.length());
2245 byte[] r = fr.apply(SPECIES.length());
2246
2247 for (int i = 0; i < a.length; i += SPECIES.length()) {
2248 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2249 av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2250 }
2251
2252 assertBroadcastLongArraysEquals(r, a, b, ByteMaxVectorTests::ADD);
2253 }
2254
2255 @Test(dataProvider = "byteBinaryOpMaskProvider")
2256 static void ADDByteMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2257 IntFunction<boolean[]> fm) {
2258 byte[] a = fa.apply(SPECIES.length());
2259 byte[] b = fb.apply(SPECIES.length());
2260 byte[] r = fr.apply(SPECIES.length());
2261 boolean[] mask = fm.apply(SPECIES.length());
2262 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2263
2264 for (int i = 0; i < a.length; i += SPECIES.length()) {
2265 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2266 av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
2267 }
2268
2269 assertBroadcastLongArraysEquals(r, a, b, mask, ByteMaxVectorTests::ADD);
2270 }
2271
2272 static byte LSHL(byte a, byte b) {
2273 return (byte)((a << (b & 0x7)));
2274 }
2275
2276 @Test(dataProvider = "byteBinaryOpProvider")
2277 static void LSHLByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2278 byte[] a = fa.apply(SPECIES.length());
2279 byte[] b = fb.apply(SPECIES.length());
2280 byte[] r = fr.apply(SPECIES.length());
2281
2282 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2283 for (int i = 0; i < a.length; i += SPECIES.length()) {
2284 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2285 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2286 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2287 }
2288 }
2289
2290 assertArraysEquals(r, a, b, ByteMaxVectorTests::LSHL);
2291 }
2292
2293 @Test(dataProvider = "byteBinaryOpMaskProvider")
2294 static void LSHLByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2295 IntFunction<boolean[]> fm) {
2296 byte[] a = fa.apply(SPECIES.length());
2297 byte[] b = fb.apply(SPECIES.length());
2298 byte[] r = fr.apply(SPECIES.length());
2299 boolean[] mask = fm.apply(SPECIES.length());
2300 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2301
2302 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2303 for (int i = 0; i < a.length; i += SPECIES.length()) {
2304 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2305 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2306 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2307 }
2308 }
2309
2310 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHL);
2311 }
2312
2313 static byte ASHR(byte a, byte b) {
2314 return (byte)((a >> (b & 0x7)));
2315 }
2316
2317 @Test(dataProvider = "byteBinaryOpProvider")
2318 static void ASHRByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2319 byte[] a = fa.apply(SPECIES.length());
2320 byte[] b = fb.apply(SPECIES.length());
2321 byte[] r = fr.apply(SPECIES.length());
2322
2323 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2324 for (int i = 0; i < a.length; i += SPECIES.length()) {
2325 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2326 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2327 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2328 }
2329 }
2330
2331 assertArraysEquals(r, a, b, ByteMaxVectorTests::ASHR);
2332 }
2333
2334 @Test(dataProvider = "byteBinaryOpMaskProvider")
2335 static void ASHRByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2336 IntFunction<boolean[]> fm) {
2337 byte[] a = fa.apply(SPECIES.length());
2338 byte[] b = fb.apply(SPECIES.length());
2339 byte[] r = fr.apply(SPECIES.length());
2340 boolean[] mask = fm.apply(SPECIES.length());
2341 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2342
2343 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2344 for (int i = 0; i < a.length; i += SPECIES.length()) {
2345 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2346 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2347 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2348 }
2349 }
2350
2351 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ASHR);
2352 }
2353
2354 static byte LSHR(byte a, byte b) {
2355 return (byte)(((a & 0xFF) >>> (b & 0x7)));
2356 }
2357
2358 @Test(dataProvider = "byteBinaryOpProvider")
2359 static void LSHRByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2360 byte[] a = fa.apply(SPECIES.length());
2361 byte[] b = fb.apply(SPECIES.length());
2362 byte[] r = fr.apply(SPECIES.length());
2363
2364 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2365 for (int i = 0; i < a.length; i += SPECIES.length()) {
2366 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2367 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2368 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2369 }
2370 }
2371
2372 assertArraysEquals(r, a, b, ByteMaxVectorTests::LSHR);
2373 }
2374
2375 @Test(dataProvider = "byteBinaryOpMaskProvider")
2376 static void LSHRByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2377 IntFunction<boolean[]> fm) {
2378 byte[] a = fa.apply(SPECIES.length());
2379 byte[] b = fb.apply(SPECIES.length());
2380 byte[] r = fr.apply(SPECIES.length());
2381 boolean[] mask = fm.apply(SPECIES.length());
2382 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2383
2384 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2385 for (int i = 0; i < a.length; i += SPECIES.length()) {
2386 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2387 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2388 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2389 }
2390 }
2391
2392 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHR);
2393 }
2394
2395 static byte LSHL_unary(byte a, byte b) {
2396 return (byte)((a << (b & 7)));
2397 }
2398
2399 @Test(dataProvider = "byteBinaryOpProvider")
2400 static void LSHLByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2401 byte[] a = fa.apply(SPECIES.length());
2402 byte[] b = fb.apply(SPECIES.length());
2403 byte[] r = fr.apply(SPECIES.length());
2404
2405 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2406 for (int i = 0; i < a.length; i += SPECIES.length()) {
2407 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2408 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2409 }
2410 }
2411
2412 assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::LSHL_unary);
2413 }
2414
2415 @Test(dataProvider = "byteBinaryOpMaskProvider")
2416 static void LSHLByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2417 IntFunction<boolean[]> fm) {
2418 byte[] a = fa.apply(SPECIES.length());
2419 byte[] b = fb.apply(SPECIES.length());
2420 byte[] r = fr.apply(SPECIES.length());
2421 boolean[] mask = fm.apply(SPECIES.length());
2422 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2423
2424 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2425 for (int i = 0; i < a.length; i += SPECIES.length()) {
2426 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2427 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2428 }
2429 }
2430
2431 assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHL_unary);
2432 }
2433
2434 static byte LSHR_unary(byte a, byte b) {
2435 return (byte)(((a & 0xFF) >>> (b & 7)));
2436 }
2437
2438 @Test(dataProvider = "byteBinaryOpProvider")
2439 static void LSHRByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2440 byte[] a = fa.apply(SPECIES.length());
2441 byte[] b = fb.apply(SPECIES.length());
2442 byte[] r = fr.apply(SPECIES.length());
2443
2444 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2445 for (int i = 0; i < a.length; i += SPECIES.length()) {
2446 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2447 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2448 }
2449 }
2450
2451 assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::LSHR_unary);
2452 }
2453
2454 @Test(dataProvider = "byteBinaryOpMaskProvider")
2455 static void LSHRByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2456 IntFunction<boolean[]> fm) {
2457 byte[] a = fa.apply(SPECIES.length());
2458 byte[] b = fb.apply(SPECIES.length());
2459 byte[] r = fr.apply(SPECIES.length());
2460 boolean[] mask = fm.apply(SPECIES.length());
2461 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2462
2463 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2464 for (int i = 0; i < a.length; i += SPECIES.length()) {
2465 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2466 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2467 }
2468 }
2469
2470 assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::LSHR_unary);
2471 }
2472
2473 static byte ASHR_unary(byte a, byte b) {
2474 return (byte)((a >> (b & 7)));
2475 }
2476
2477 @Test(dataProvider = "byteBinaryOpProvider")
2478 static void ASHRByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2479 byte[] a = fa.apply(SPECIES.length());
2480 byte[] b = fb.apply(SPECIES.length());
2481 byte[] r = fr.apply(SPECIES.length());
2482
2483 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2484 for (int i = 0; i < a.length; i += SPECIES.length()) {
2485 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2486 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2487 }
2488 }
2489
2490 assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ASHR_unary);
2491 }
2492
2493 @Test(dataProvider = "byteBinaryOpMaskProvider")
2494 static void ASHRByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2495 IntFunction<boolean[]> fm) {
2496 byte[] a = fa.apply(SPECIES.length());
2497 byte[] b = fb.apply(SPECIES.length());
2498 byte[] r = fr.apply(SPECIES.length());
2499 boolean[] mask = fm.apply(SPECIES.length());
2500 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2501
2502 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2503 for (int i = 0; i < a.length; i += SPECIES.length()) {
2504 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2505 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2506 }
2507 }
2508
2509 assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ASHR_unary);
2510 }
2511
2512 static byte ROR(byte a, byte b) {
2513 return (byte)(ROR_scalar(a,b));
2514 }
2515
2516 @Test(dataProvider = "byteBinaryOpProvider")
2517 static void RORByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2518 byte[] a = fa.apply(SPECIES.length());
2519 byte[] b = fb.apply(SPECIES.length());
2520 byte[] r = fr.apply(SPECIES.length());
2521
2522 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2523 for (int i = 0; i < a.length; i += SPECIES.length()) {
2524 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2525 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2526 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2527 }
2528 }
2529
2530 assertArraysEquals(r, a, b, ByteMaxVectorTests::ROR);
2531 }
2532
2533 @Test(dataProvider = "byteBinaryOpMaskProvider")
2534 static void RORByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2535 IntFunction<boolean[]> fm) {
2536 byte[] a = fa.apply(SPECIES.length());
2537 byte[] b = fb.apply(SPECIES.length());
2538 byte[] r = fr.apply(SPECIES.length());
2539 boolean[] mask = fm.apply(SPECIES.length());
2540 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2541
2542 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2543 for (int i = 0; i < a.length; i += SPECIES.length()) {
2544 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2545 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2546 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2547 }
2548 }
2549
2550 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROR);
2551 }
2552
2553 static byte ROL(byte a, byte b) {
2554 return (byte)(ROL_scalar(a,b));
2555 }
2556
2557 @Test(dataProvider = "byteBinaryOpProvider")
2558 static void ROLByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2559 byte[] a = fa.apply(SPECIES.length());
2560 byte[] b = fb.apply(SPECIES.length());
2561 byte[] r = fr.apply(SPECIES.length());
2562
2563 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2564 for (int i = 0; i < a.length; i += SPECIES.length()) {
2565 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2566 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2567 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2568 }
2569 }
2570
2571 assertArraysEquals(r, a, b, ByteMaxVectorTests::ROL);
2572 }
2573
2574 @Test(dataProvider = "byteBinaryOpMaskProvider")
2575 static void ROLByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2576 IntFunction<boolean[]> fm) {
2577 byte[] a = fa.apply(SPECIES.length());
2578 byte[] b = fb.apply(SPECIES.length());
2579 byte[] r = fr.apply(SPECIES.length());
2580 boolean[] mask = fm.apply(SPECIES.length());
2581 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2582
2583 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2584 for (int i = 0; i < a.length; i += SPECIES.length()) {
2585 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2586 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2587 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2588 }
2589 }
2590
2591 assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROL);
2592 }
2593
2594 static byte ROR_unary(byte a, byte b) {
2595 return (byte)(ROR_scalar(a, b));
2596 }
2597
2598 @Test(dataProvider = "byteBinaryOpProvider")
2599 static void RORByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2600 byte[] a = fa.apply(SPECIES.length());
2601 byte[] b = fb.apply(SPECIES.length());
2602 byte[] r = fr.apply(SPECIES.length());
2603
2604 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2605 for (int i = 0; i < a.length; i += SPECIES.length()) {
2606 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2607 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2608 }
2609 }
2610
2611 assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ROR_unary);
2612 }
2613
2614 @Test(dataProvider = "byteBinaryOpMaskProvider")
2615 static void RORByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2616 IntFunction<boolean[]> fm) {
2617 byte[] a = fa.apply(SPECIES.length());
2618 byte[] b = fb.apply(SPECIES.length());
2619 byte[] r = fr.apply(SPECIES.length());
2620 boolean[] mask = fm.apply(SPECIES.length());
2621 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2622
2623 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2624 for (int i = 0; i < a.length; i += SPECIES.length()) {
2625 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2626 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2627 }
2628 }
2629
2630 assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROR_unary);
2631 }
2632
2633 static byte ROL_unary(byte a, byte b) {
2634 return (byte)(ROL_scalar(a, b));
2635 }
2636
2637 @Test(dataProvider = "byteBinaryOpProvider")
2638 static void ROLByteMaxVectorTestsScalarShift(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2639 byte[] a = fa.apply(SPECIES.length());
2640 byte[] b = fb.apply(SPECIES.length());
2641 byte[] r = fr.apply(SPECIES.length());
2642
2643 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2644 for (int i = 0; i < a.length; i += SPECIES.length()) {
2645 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2646 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2647 }
2648 }
2649
2650 assertShiftArraysEquals(r, a, b, ByteMaxVectorTests::ROL_unary);
2651 }
2652
2653 @Test(dataProvider = "byteBinaryOpMaskProvider")
2654 static void ROLByteMaxVectorTestsScalarShiftMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
2655 IntFunction<boolean[]> fm) {
2656 byte[] a = fa.apply(SPECIES.length());
2657 byte[] b = fb.apply(SPECIES.length());
2658 byte[] r = fr.apply(SPECIES.length());
2659 boolean[] mask = fm.apply(SPECIES.length());
2660 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2661
2662 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2663 for (int i = 0; i < a.length; i += SPECIES.length()) {
2664 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2665 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2666 }
2667 }
2668
2669 assertShiftArraysEquals(r, a, b, mask, ByteMaxVectorTests::ROL_unary);
2670 }
2671 static byte LSHR_binary_const(byte a) {
2672 return (byte)(((a & 0xFF) >>> CONST_SHIFT));
2673 }
2674
2675 @Test(dataProvider = "byteUnaryOpProvider")
2676 static void LSHRByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2677 byte[] a = fa.apply(SPECIES.length());
2678 byte[] r = fr.apply(SPECIES.length());
2679
2680 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2681 for (int i = 0; i < a.length; i += SPECIES.length()) {
2682 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2683 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
2684 }
2685 }
2686
2687 assertShiftConstEquals(r, a, ByteMaxVectorTests::LSHR_binary_const);
2688 }
2689
2690 @Test(dataProvider = "byteUnaryOpMaskProvider")
2691 static void LSHRByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2692 IntFunction<boolean[]> fm) {
2693 byte[] a = fa.apply(SPECIES.length());
2694 byte[] r = fr.apply(SPECIES.length());
2695 boolean[] mask = fm.apply(SPECIES.length());
2696 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2697
2698 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2699 for (int i = 0; i < a.length; i += SPECIES.length()) {
2700 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2701 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
2702 }
2703 }
2704
2705 assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::LSHR_binary_const);
2706 }
2707
2708 static byte LSHL_binary_const(byte a) {
2709 return (byte)((a << CONST_SHIFT));
2710 }
2711
2712 @Test(dataProvider = "byteUnaryOpProvider")
2713 static void LSHLByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2714 byte[] a = fa.apply(SPECIES.length());
2715 byte[] r = fr.apply(SPECIES.length());
2716
2717 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2718 for (int i = 0; i < a.length; i += SPECIES.length()) {
2719 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2720 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
2721 }
2722 }
2723
2724 assertShiftConstEquals(r, a, ByteMaxVectorTests::LSHL_binary_const);
2725 }
2726
2727 @Test(dataProvider = "byteUnaryOpMaskProvider")
2728 static void LSHLByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2729 IntFunction<boolean[]> fm) {
2730 byte[] a = fa.apply(SPECIES.length());
2731 byte[] r = fr.apply(SPECIES.length());
2732 boolean[] mask = fm.apply(SPECIES.length());
2733 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2734
2735 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2736 for (int i = 0; i < a.length; i += SPECIES.length()) {
2737 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2738 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
2739 }
2740 }
2741
2742 assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::LSHL_binary_const);
2743 }
2744
2745 static byte ASHR_binary_const(byte a) {
2746 return (byte)((a >> CONST_SHIFT));
2747 }
2748
2749 @Test(dataProvider = "byteUnaryOpProvider")
2750 static void ASHRByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2751 byte[] a = fa.apply(SPECIES.length());
2752 byte[] r = fr.apply(SPECIES.length());
2753
2754 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2755 for (int i = 0; i < a.length; i += SPECIES.length()) {
2756 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2757 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
2758 }
2759 }
2760
2761 assertShiftConstEquals(r, a, ByteMaxVectorTests::ASHR_binary_const);
2762 }
2763
2764 @Test(dataProvider = "byteUnaryOpMaskProvider")
2765 static void ASHRByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2766 IntFunction<boolean[]> fm) {
2767 byte[] a = fa.apply(SPECIES.length());
2768 byte[] r = fr.apply(SPECIES.length());
2769 boolean[] mask = fm.apply(SPECIES.length());
2770 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2771
2772 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2773 for (int i = 0; i < a.length; i += SPECIES.length()) {
2774 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2775 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
2776 }
2777 }
2778
2779 assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ASHR_binary_const);
2780 }
2781
2782 static byte ROR_binary_const(byte a) {
2783 return (byte)(ROR_scalar(a, CONST_SHIFT));
2784 }
2785
2786 @Test(dataProvider = "byteUnaryOpProvider")
2787 static void RORByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2788 byte[] a = fa.apply(SPECIES.length());
2789 byte[] r = fr.apply(SPECIES.length());
2790
2791 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2792 for (int i = 0; i < a.length; i += SPECIES.length()) {
2793 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2794 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
2795 }
2796 }
2797
2798 assertShiftConstEquals(r, a, ByteMaxVectorTests::ROR_binary_const);
2799 }
2800
2801 @Test(dataProvider = "byteUnaryOpMaskProvider")
2802 static void RORByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2803 IntFunction<boolean[]> fm) {
2804 byte[] a = fa.apply(SPECIES.length());
2805 byte[] r = fr.apply(SPECIES.length());
2806 boolean[] mask = fm.apply(SPECIES.length());
2807 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2808
2809 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2810 for (int i = 0; i < a.length; i += SPECIES.length()) {
2811 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2812 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
2813 }
2814 }
2815
2816 assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ROR_binary_const);
2817 }
2818
2819 static byte ROL_binary_const(byte a) {
2820 return (byte)(ROL_scalar(a, CONST_SHIFT));
2821 }
2822
2823 @Test(dataProvider = "byteUnaryOpProvider")
2824 static void ROLByteMaxVectorTestsScalarShiftConst(IntFunction<byte[]> fa) {
2825 byte[] a = fa.apply(SPECIES.length());
2826 byte[] r = fr.apply(SPECIES.length());
2827
2828 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2829 for (int i = 0; i < a.length; i += SPECIES.length()) {
2830 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2831 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
2832 }
2833 }
2834
2835 assertShiftConstEquals(r, a, ByteMaxVectorTests::ROL_binary_const);
2836 }
2837
2838 @Test(dataProvider = "byteUnaryOpMaskProvider")
2839 static void ROLByteMaxVectorTestsScalarShiftMaskedConst(IntFunction<byte[]> fa,
2840 IntFunction<boolean[]> fm) {
2841 byte[] a = fa.apply(SPECIES.length());
2842 byte[] r = fr.apply(SPECIES.length());
2843 boolean[] mask = fm.apply(SPECIES.length());
2844 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2845
2846 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2847 for (int i = 0; i < a.length; i += SPECIES.length()) {
2848 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2849 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
2850 }
2851 }
2852
2853 assertShiftConstEquals(r, a, mask, ByteMaxVectorTests::ROL_binary_const);
2854 }
2855
2856
2857 static byte MIN(byte a, byte b) {
2858 return (byte)(Math.min(a, b));
2859 }
2860
2861 @Test(dataProvider = "byteBinaryOpProvider")
2862 static void MINByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2863 byte[] a = fa.apply(SPECIES.length());
2864 byte[] b = fb.apply(SPECIES.length());
2865 byte[] r = fr.apply(SPECIES.length());
2866
2867 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2868 for (int i = 0; i < a.length; i += SPECIES.length()) {
2869 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2870 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2871 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2872 }
2873 }
2874
2875 assertArraysEquals(r, a, b, ByteMaxVectorTests::MIN);
2876 }
2877
2878 static byte min(byte a, byte b) {
2879 return (byte)(Math.min(a, b));
2880 }
2881
2882 @Test(dataProvider = "byteBinaryOpProvider")
2883 static void minByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2884 byte[] a = fa.apply(SPECIES.length());
2885 byte[] b = fb.apply(SPECIES.length());
2886 byte[] r = fr.apply(SPECIES.length());
2887
2888 for (int i = 0; i < a.length; i += SPECIES.length()) {
2889 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2890 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2891 av.min(bv).intoArray(r, i);
2892 }
2893
2894 assertArraysEquals(r, a, b, ByteMaxVectorTests::min);
2895 }
2896
2897 static byte MAX(byte a, byte b) {
2898 return (byte)(Math.max(a, b));
2899 }
2900
2901 @Test(dataProvider = "byteBinaryOpProvider")
2902 static void MAXByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2903 byte[] a = fa.apply(SPECIES.length());
2904 byte[] b = fb.apply(SPECIES.length());
2905 byte[] r = fr.apply(SPECIES.length());
2906
2907 for (int ic = 0; ic < INVOC_COUNT; ic++) {
2908 for (int i = 0; i < a.length; i += SPECIES.length()) {
2909 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2910 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2911 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2912 }
2913 }
2914
2915 assertArraysEquals(r, a, b, ByteMaxVectorTests::MAX);
2916 }
2917
2918 static byte max(byte a, byte b) {
2919 return (byte)(Math.max(a, b));
2920 }
2921
2922 @Test(dataProvider = "byteBinaryOpProvider")
2923 static void maxByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
2924 byte[] a = fa.apply(SPECIES.length());
2925 byte[] b = fb.apply(SPECIES.length());
2926 byte[] r = fr.apply(SPECIES.length());
2927
2928 for (int i = 0; i < a.length; i += SPECIES.length()) {
2929 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
2930 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
2931 av.max(bv).intoArray(r, i);
2932 }
2933
2934 assertArraysEquals(r, a, b, ByteMaxVectorTests::max);
2935 }
2936
2937 @Test(dataProvider = "byteBinaryOpProvider")
2991 }
2992
2993 static byte ANDReduce(byte[] a, int idx) {
2994 byte res = -1;
2995 for (int i = idx; i < (idx + SPECIES.length()); i++) {
2996 res &= a[i];
2997 }
2998
2999 return res;
3000 }
3001
3002 static byte ANDReduceAll(byte[] a) {
3003 byte res = -1;
3004 for (int i = 0; i < a.length; i += SPECIES.length()) {
3005 res &= ANDReduce(a, i);
3006 }
3007
3008 return res;
3009 }
3010
3011 @Test(dataProvider = "byteUnaryOpProvider")
3012 static void ANDReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3013 byte[] a = fa.apply(SPECIES.length());
3014 byte[] r = fr.apply(SPECIES.length());
3015 byte ra = -1;
3016
3017 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3018 for (int i = 0; i < a.length; i += SPECIES.length()) {
3019 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3020 r[i] = av.reduceLanes(VectorOperators.AND);
3021 }
3022 }
3023
3024 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3025 ra = -1;
3026 for (int i = 0; i < a.length; i += SPECIES.length()) {
3027 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3028 ra &= av.reduceLanes(VectorOperators.AND);
3029 }
3030 }
3031
3032 assertReductionArraysEquals(r, ra, a,
3033 ByteMaxVectorTests::ANDReduce, ByteMaxVectorTests::ANDReduceAll);
3034 }
3035
3036 static byte ANDReduceMasked(byte[] a, int idx, boolean[] mask) {
3037 byte res = -1;
3038 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3039 if (mask[i % SPECIES.length()])
3040 res &= a[i];
3041 }
3042
3043 return res;
3044 }
3045
3046 static byte ANDReduceAllMasked(byte[] a, boolean[] mask) {
3047 byte res = -1;
3048 for (int i = 0; i < a.length; i += SPECIES.length()) {
3049 res &= ANDReduceMasked(a, i, mask);
3050 }
3051
3052 return res;
3053 }
3054
3055 @Test(dataProvider = "byteUnaryOpMaskProvider")
3056 static void ANDReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3057 byte[] a = fa.apply(SPECIES.length());
3058 byte[] r = fr.apply(SPECIES.length());
3059 boolean[] mask = fm.apply(SPECIES.length());
3060 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3061 byte ra = -1;
3062
3063 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3064 for (int i = 0; i < a.length; i += SPECIES.length()) {
3065 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3066 r[i] = av.reduceLanes(VectorOperators.AND, vmask);
3067 }
3068 }
3069
3070 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3071 ra = -1;
3072 for (int i = 0; i < a.length; i += SPECIES.length()) {
3073 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3074 ra &= av.reduceLanes(VectorOperators.AND, vmask);
3075 }
3076 }
3077
3078 assertReductionArraysEqualsMasked(r, ra, a, mask,
3079 ByteMaxVectorTests::ANDReduceMasked, ByteMaxVectorTests::ANDReduceAllMasked);
3080 }
3081
3082 static byte ORReduce(byte[] a, int idx) {
3083 byte res = 0;
3084 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3085 res |= a[i];
3086 }
3087
3088 return res;
3089 }
3090
3091 static byte ORReduceAll(byte[] a) {
3092 byte res = 0;
3093 for (int i = 0; i < a.length; i += SPECIES.length()) {
3094 res |= ORReduce(a, i);
3095 }
3096
3097 return res;
3098 }
3099
3100 @Test(dataProvider = "byteUnaryOpProvider")
3101 static void ORReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3102 byte[] a = fa.apply(SPECIES.length());
3103 byte[] r = fr.apply(SPECIES.length());
3104 byte ra = 0;
3105
3106 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3107 for (int i = 0; i < a.length; i += SPECIES.length()) {
3108 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3109 r[i] = av.reduceLanes(VectorOperators.OR);
3110 }
3111 }
3112
3113 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3114 ra = 0;
3115 for (int i = 0; i < a.length; i += SPECIES.length()) {
3116 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3117 ra |= av.reduceLanes(VectorOperators.OR);
3118 }
3119 }
3120
3121 assertReductionArraysEquals(r, ra, a,
3122 ByteMaxVectorTests::ORReduce, ByteMaxVectorTests::ORReduceAll);
3123 }
3124
3125 static byte ORReduceMasked(byte[] a, int idx, boolean[] mask) {
3126 byte res = 0;
3127 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3128 if (mask[i % SPECIES.length()])
3129 res |= a[i];
3130 }
3131
3132 return res;
3133 }
3134
3135 static byte ORReduceAllMasked(byte[] a, boolean[] mask) {
3136 byte res = 0;
3137 for (int i = 0; i < a.length; i += SPECIES.length()) {
3138 res |= ORReduceMasked(a, i, mask);
3139 }
3140
3141 return res;
3142 }
3143
3144 @Test(dataProvider = "byteUnaryOpMaskProvider")
3145 static void ORReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3146 byte[] a = fa.apply(SPECIES.length());
3147 byte[] r = fr.apply(SPECIES.length());
3148 boolean[] mask = fm.apply(SPECIES.length());
3149 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3150 byte ra = 0;
3151
3152 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3153 for (int i = 0; i < a.length; i += SPECIES.length()) {
3154 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3155 r[i] = av.reduceLanes(VectorOperators.OR, vmask);
3156 }
3157 }
3158
3159 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3160 ra = 0;
3161 for (int i = 0; i < a.length; i += SPECIES.length()) {
3162 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3163 ra |= av.reduceLanes(VectorOperators.OR, vmask);
3164 }
3165 }
3166
3167 assertReductionArraysEqualsMasked(r, ra, a, mask,
3168 ByteMaxVectorTests::ORReduceMasked, ByteMaxVectorTests::ORReduceAllMasked);
3169 }
3170
3171 static byte XORReduce(byte[] a, int idx) {
3172 byte res = 0;
3173 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3174 res ^= a[i];
3175 }
3176
3177 return res;
3178 }
3179
3180 static byte XORReduceAll(byte[] a) {
3181 byte res = 0;
3182 for (int i = 0; i < a.length; i += SPECIES.length()) {
3183 res ^= XORReduce(a, i);
3184 }
3185
3186 return res;
3187 }
3188
3189 @Test(dataProvider = "byteUnaryOpProvider")
3190 static void XORReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3191 byte[] a = fa.apply(SPECIES.length());
3192 byte[] r = fr.apply(SPECIES.length());
3193 byte ra = 0;
3194
3195 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3196 for (int i = 0; i < a.length; i += SPECIES.length()) {
3197 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3198 r[i] = av.reduceLanes(VectorOperators.XOR);
3199 }
3200 }
3201
3202 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3203 ra = 0;
3204 for (int i = 0; i < a.length; i += SPECIES.length()) {
3205 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3206 ra ^= av.reduceLanes(VectorOperators.XOR);
3207 }
3208 }
3209
3210 assertReductionArraysEquals(r, ra, a,
3211 ByteMaxVectorTests::XORReduce, ByteMaxVectorTests::XORReduceAll);
3212 }
3213
3214 static byte XORReduceMasked(byte[] a, int idx, boolean[] mask) {
3215 byte res = 0;
3216 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3217 if (mask[i % SPECIES.length()])
3218 res ^= a[i];
3219 }
3220
3221 return res;
3222 }
3223
3224 static byte XORReduceAllMasked(byte[] a, boolean[] mask) {
3225 byte res = 0;
3226 for (int i = 0; i < a.length; i += SPECIES.length()) {
3227 res ^= XORReduceMasked(a, i, mask);
3228 }
3229
3230 return res;
3231 }
3232
3233 @Test(dataProvider = "byteUnaryOpMaskProvider")
3234 static void XORReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3235 byte[] a = fa.apply(SPECIES.length());
3236 byte[] r = fr.apply(SPECIES.length());
3237 boolean[] mask = fm.apply(SPECIES.length());
3238 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3239 byte ra = 0;
3240
3241 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3242 for (int i = 0; i < a.length; i += SPECIES.length()) {
3243 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3244 r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
3245 }
3246 }
3247
3248 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3249 ra = 0;
3250 for (int i = 0; i < a.length; i += SPECIES.length()) {
3251 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3252 ra ^= av.reduceLanes(VectorOperators.XOR, vmask);
3257 ByteMaxVectorTests::XORReduceMasked, ByteMaxVectorTests::XORReduceAllMasked);
3258 }
3259
3260 static byte ADDReduce(byte[] a, int idx) {
3261 byte res = 0;
3262 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3263 res += a[i];
3264 }
3265
3266 return res;
3267 }
3268
3269 static byte ADDReduceAll(byte[] a) {
3270 byte res = 0;
3271 for (int i = 0; i < a.length; i += SPECIES.length()) {
3272 res += ADDReduce(a, i);
3273 }
3274
3275 return res;
3276 }
3277
3278 @Test(dataProvider = "byteUnaryOpProvider")
3279 static void ADDReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3280 byte[] a = fa.apply(SPECIES.length());
3281 byte[] r = fr.apply(SPECIES.length());
3282 byte ra = 0;
3283
3284 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3285 for (int i = 0; i < a.length; i += SPECIES.length()) {
3286 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3287 r[i] = av.reduceLanes(VectorOperators.ADD);
3288 }
3289 }
3290
3291 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3292 ra = 0;
3293 for (int i = 0; i < a.length; i += SPECIES.length()) {
3294 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3295 ra += av.reduceLanes(VectorOperators.ADD);
3296 }
3297 }
3298
3299 assertReductionArraysEquals(r, ra, a,
3300 ByteMaxVectorTests::ADDReduce, ByteMaxVectorTests::ADDReduceAll);
3301 }
3302
3303 static byte ADDReduceMasked(byte[] a, int idx, boolean[] mask) {
3304 byte res = 0;
3305 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3306 if (mask[i % SPECIES.length()])
3307 res += a[i];
3308 }
3309
3310 return res;
3311 }
3312
3313 static byte ADDReduceAllMasked(byte[] a, boolean[] mask) {
3314 byte res = 0;
3315 for (int i = 0; i < a.length; i += SPECIES.length()) {
3316 res += ADDReduceMasked(a, i, mask);
3317 }
3318
3319 return res;
3320 }
3321
3322 @Test(dataProvider = "byteUnaryOpMaskProvider")
3323 static void ADDReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3324 byte[] a = fa.apply(SPECIES.length());
3325 byte[] r = fr.apply(SPECIES.length());
3326 boolean[] mask = fm.apply(SPECIES.length());
3327 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3328 byte ra = 0;
3329
3330 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3331 for (int i = 0; i < a.length; i += SPECIES.length()) {
3332 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3333 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3334 }
3335 }
3336
3337 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3338 ra = 0;
3339 for (int i = 0; i < a.length; i += SPECIES.length()) {
3340 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3341 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3342 }
3343 }
3344
3345 assertReductionArraysEqualsMasked(r, ra, a, mask,
3346 ByteMaxVectorTests::ADDReduceMasked, ByteMaxVectorTests::ADDReduceAllMasked);
3347 }
3348
3349 static byte MULReduce(byte[] a, int idx) {
3350 byte res = 1;
3351 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3352 res *= a[i];
3353 }
3354
3355 return res;
3356 }
3357
3358 static byte MULReduceAll(byte[] a) {
3359 byte res = 1;
3360 for (int i = 0; i < a.length; i += SPECIES.length()) {
3361 res *= MULReduce(a, i);
3362 }
3363
3364 return res;
3365 }
3366
3367 @Test(dataProvider = "byteUnaryOpProvider")
3368 static void MULReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3369 byte[] a = fa.apply(SPECIES.length());
3370 byte[] r = fr.apply(SPECIES.length());
3371 byte ra = 1;
3372
3373 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3374 for (int i = 0; i < a.length; i += SPECIES.length()) {
3375 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3376 r[i] = av.reduceLanes(VectorOperators.MUL);
3377 }
3378 }
3379
3380 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3381 ra = 1;
3382 for (int i = 0; i < a.length; i += SPECIES.length()) {
3383 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3384 ra *= av.reduceLanes(VectorOperators.MUL);
3385 }
3386 }
3387
3388 assertReductionArraysEquals(r, ra, a,
3389 ByteMaxVectorTests::MULReduce, ByteMaxVectorTests::MULReduceAll);
3390 }
3391
3392 static byte MULReduceMasked(byte[] a, int idx, boolean[] mask) {
3393 byte res = 1;
3394 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3395 if (mask[i % SPECIES.length()])
3396 res *= a[i];
3397 }
3398
3399 return res;
3400 }
3401
3402 static byte MULReduceAllMasked(byte[] a, boolean[] mask) {
3403 byte res = 1;
3404 for (int i = 0; i < a.length; i += SPECIES.length()) {
3405 res *= MULReduceMasked(a, i, mask);
3406 }
3407
3408 return res;
3409 }
3410
3411 @Test(dataProvider = "byteUnaryOpMaskProvider")
3412 static void MULReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3413 byte[] a = fa.apply(SPECIES.length());
3414 byte[] r = fr.apply(SPECIES.length());
3415 boolean[] mask = fm.apply(SPECIES.length());
3416 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3417 byte ra = 1;
3418
3419 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3420 for (int i = 0; i < a.length; i += SPECIES.length()) {
3421 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3422 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3423 }
3424 }
3425
3426 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3427 ra = 1;
3428 for (int i = 0; i < a.length; i += SPECIES.length()) {
3429 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3430 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
3431 }
3432 }
3433
3434 assertReductionArraysEqualsMasked(r, ra, a, mask,
3435 ByteMaxVectorTests::MULReduceMasked, ByteMaxVectorTests::MULReduceAllMasked);
3436 }
3437
3438 static byte MINReduce(byte[] a, int idx) {
3439 byte res = Byte.MAX_VALUE;
3440 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3441 res = (byte) Math.min(res, a[i]);
3442 }
3443
3444 return res;
3445 }
3446
3447 static byte MINReduceAll(byte[] a) {
3448 byte res = Byte.MAX_VALUE;
3449 for (int i = 0; i < a.length; i += SPECIES.length()) {
3450 res = (byte) Math.min(res, MINReduce(a, i));
3451 }
3452
3453 return res;
3454 }
3455
3456 @Test(dataProvider = "byteUnaryOpProvider")
3457 static void MINReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3458 byte[] a = fa.apply(SPECIES.length());
3459 byte[] r = fr.apply(SPECIES.length());
3460 byte ra = Byte.MAX_VALUE;
3461
3462 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3463 for (int i = 0; i < a.length; i += SPECIES.length()) {
3464 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3465 r[i] = av.reduceLanes(VectorOperators.MIN);
3466 }
3467 }
3468
3469 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3470 ra = Byte.MAX_VALUE;
3471 for (int i = 0; i < a.length; i += SPECIES.length()) {
3472 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3473 ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
3474 }
3475 }
3476
3477 assertReductionArraysEquals(r, ra, a,
3478 ByteMaxVectorTests::MINReduce, ByteMaxVectorTests::MINReduceAll);
3479 }
3480
3481 static byte MINReduceMasked(byte[] a, int idx, boolean[] mask) {
3482 byte res = Byte.MAX_VALUE;
3483 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3484 if (mask[i % SPECIES.length()])
3485 res = (byte) Math.min(res, a[i]);
3486 }
3487
3488 return res;
3489 }
3490
3491 static byte MINReduceAllMasked(byte[] a, boolean[] mask) {
3492 byte res = Byte.MAX_VALUE;
3493 for (int i = 0; i < a.length; i += SPECIES.length()) {
3494 res = (byte) Math.min(res, MINReduceMasked(a, i, mask));
3495 }
3496
3497 return res;
3498 }
3499
3500 @Test(dataProvider = "byteUnaryOpMaskProvider")
3501 static void MINReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3502 byte[] a = fa.apply(SPECIES.length());
3503 byte[] r = fr.apply(SPECIES.length());
3504 boolean[] mask = fm.apply(SPECIES.length());
3505 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3506 byte ra = Byte.MAX_VALUE;
3507
3508 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3509 for (int i = 0; i < a.length; i += SPECIES.length()) {
3510 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3511 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
3512 }
3513 }
3514
3515 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3516 ra = Byte.MAX_VALUE;
3517 for (int i = 0; i < a.length; i += SPECIES.length()) {
3518 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3519 ra = (byte) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
3520 }
3521 }
3522
3523 assertReductionArraysEqualsMasked(r, ra, a, mask,
3524 ByteMaxVectorTests::MINReduceMasked, ByteMaxVectorTests::MINReduceAllMasked);
3525 }
3526
3527 static byte MAXReduce(byte[] a, int idx) {
3528 byte res = Byte.MIN_VALUE;
3529 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3530 res = (byte) Math.max(res, a[i]);
3531 }
3532
3533 return res;
3534 }
3535
3536 static byte MAXReduceAll(byte[] a) {
3537 byte res = Byte.MIN_VALUE;
3538 for (int i = 0; i < a.length; i += SPECIES.length()) {
3539 res = (byte) Math.max(res, MAXReduce(a, i));
3540 }
3541
3542 return res;
3543 }
3544
3545 @Test(dataProvider = "byteUnaryOpProvider")
3546 static void MAXReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3547 byte[] a = fa.apply(SPECIES.length());
3548 byte[] r = fr.apply(SPECIES.length());
3549 byte ra = Byte.MIN_VALUE;
3550
3551 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3552 for (int i = 0; i < a.length; i += SPECIES.length()) {
3553 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3554 r[i] = av.reduceLanes(VectorOperators.MAX);
3555 }
3556 }
3557
3558 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3559 ra = Byte.MIN_VALUE;
3560 for (int i = 0; i < a.length; i += SPECIES.length()) {
3561 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3562 ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
3563 }
3564 }
3565
3566 assertReductionArraysEquals(r, ra, a,
3567 ByteMaxVectorTests::MAXReduce, ByteMaxVectorTests::MAXReduceAll);
3568 }
3569
3570 static byte MAXReduceMasked(byte[] a, int idx, boolean[] mask) {
3571 byte res = Byte.MIN_VALUE;
3572 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3573 if (mask[i % SPECIES.length()])
3574 res = (byte) Math.max(res, a[i]);
3575 }
3576
3577 return res;
3578 }
3579
3580 static byte MAXReduceAllMasked(byte[] a, boolean[] mask) {
3581 byte res = Byte.MIN_VALUE;
3582 for (int i = 0; i < a.length; i += SPECIES.length()) {
3583 res = (byte) Math.max(res, MAXReduceMasked(a, i, mask));
3584 }
3585
3586 return res;
3587 }
3588
3589 @Test(dataProvider = "byteUnaryOpMaskProvider")
3590 static void MAXReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3591 byte[] a = fa.apply(SPECIES.length());
3592 byte[] r = fr.apply(SPECIES.length());
3593 boolean[] mask = fm.apply(SPECIES.length());
3594 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3595 byte ra = Byte.MIN_VALUE;
3596
3597 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3598 for (int i = 0; i < a.length; i += SPECIES.length()) {
3599 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3600 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
3601 }
3602 }
3603
3604 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3605 ra = Byte.MIN_VALUE;
3606 for (int i = 0; i < a.length; i += SPECIES.length()) {
3607 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3608 ra = (byte) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
3609 }
3610 }
3611
3612 assertReductionArraysEqualsMasked(r, ra, a, mask,
3613 ByteMaxVectorTests::MAXReduceMasked, ByteMaxVectorTests::MAXReduceAllMasked);
3614 }
3615
3616 static byte FIRST_NONZEROReduce(byte[] a, int idx) {
3617 byte res = (byte) 0;
3618 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3619 res = firstNonZero(res, a[i]);
3620 }
3621
3622 return res;
3623 }
3624
3625 static byte FIRST_NONZEROReduceAll(byte[] a) {
3626 byte res = (byte) 0;
3627 for (int i = 0; i < a.length; i += SPECIES.length()) {
3628 res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
3629 }
3630
3631 return res;
3632 }
3633
3634 @Test(dataProvider = "byteUnaryOpProvider")
3635 static void FIRST_NONZEROReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
3636 byte[] a = fa.apply(SPECIES.length());
3637 byte[] r = fr.apply(SPECIES.length());
3638 byte ra = (byte) 0;
3639
3640 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3641 for (int i = 0; i < a.length; i += SPECIES.length()) {
3642 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3643 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
3644 }
3645 }
3646
3647 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3648 ra = (byte) 0;
3649 for (int i = 0; i < a.length; i += SPECIES.length()) {
3650 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3651 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
3652 }
3653 }
3654
3655 assertReductionArraysEquals(r, ra, a,
3656 ByteMaxVectorTests::FIRST_NONZEROReduce, ByteMaxVectorTests::FIRST_NONZEROReduceAll);
3657 }
3658
3659 static byte FIRST_NONZEROReduceMasked(byte[] a, int idx, boolean[] mask) {
3660 byte res = (byte) 0;
3661 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3662 if (mask[i % SPECIES.length()])
3663 res = firstNonZero(res, a[i]);
3664 }
3665
3666 return res;
3667 }
3668
3669 static byte FIRST_NONZEROReduceAllMasked(byte[] a, boolean[] mask) {
3670 byte res = (byte) 0;
3671 for (int i = 0; i < a.length; i += SPECIES.length()) {
3672 res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
3673 }
3674
3675 return res;
3676 }
3677
3678 @Test(dataProvider = "byteUnaryOpMaskProvider")
3679 static void FIRST_NONZEROReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
3680 byte[] a = fa.apply(SPECIES.length());
3681 byte[] r = fr.apply(SPECIES.length());
3682 boolean[] mask = fm.apply(SPECIES.length());
3683 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3684 byte ra = (byte) 0;
3685
3686 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3687 for (int i = 0; i < a.length; i += SPECIES.length()) {
3688 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3689 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
3690 }
3691 }
3692
3693 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3694 ra = (byte) 0;
3695 for (int i = 0; i < a.length; i += SPECIES.length()) {
3696 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3697 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
3698 }
3699 }
3700
3701 assertReductionArraysEqualsMasked(r, ra, a, mask,
3702 ByteMaxVectorTests::FIRST_NONZEROReduceMasked, ByteMaxVectorTests::FIRST_NONZEROReduceAllMasked);
3703 }
3704
3705 static boolean anyTrue(boolean[] a, int idx) {
3706 boolean res = false;
3707 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3708 res |= a[i];
3709 }
3710
3711 return res;
3712 }
3713
3714 @Test(dataProvider = "boolUnaryOpProvider")
3715 static void anyTrueByteMaxVectorTests(IntFunction<boolean[]> fm) {
3716 boolean[] mask = fm.apply(SPECIES.length());
3717 boolean[] r = fmr.apply(SPECIES.length());
3718
3719 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3720 for (int i = 0; i < mask.length; i += SPECIES.length()) {
3721 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, i);
3722 r[i] = vmask.anyTrue();
3723 }
3724 }
3725
3726 assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::anyTrue);
3727 }
3728
3729 static boolean allTrue(boolean[] a, int idx) {
3730 boolean res = true;
3731 for (int i = idx; i < (idx + SPECIES.length()); i++) {
3732 res &= a[i];
3733 }
3734
3735 return res;
3736 }
3737
3738 @Test(dataProvider = "boolUnaryOpProvider")
3739 static void allTrueByteMaxVectorTests(IntFunction<boolean[]> fm) {
3740 boolean[] mask = fm.apply(SPECIES.length());
3741 boolean[] r = fmr.apply(SPECIES.length());
3742
3743 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3744 for (int i = 0; i < mask.length; i += SPECIES.length()) {
3745 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, i);
3746 r[i] = vmask.allTrue();
3747 }
3748 }
3749
3750 assertReductionBoolArraysEquals(r, mask, ByteMaxVectorTests::allTrue);
3751 }
3752
3753 @Test(dataProvider = "byteUnaryOpProvider")
3754 static void withByteMaxVectorTests(IntFunction<byte []> fa) {
3755 byte[] a = fa.apply(SPECIES.length());
3756 byte[] r = fr.apply(SPECIES.length());
3757
3758 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3759 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3760 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3761 av.withLane((j++ & (SPECIES.length()-1)), (byte)(65535+i)).intoArray(r, i);
3762 }
3763 }
3764
3765
3766 for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3767 assertInsertArraysEquals(r, a, (byte)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
3768 }
3769 }
3770
3771 static boolean testIS_DEFAULT(byte a) {
3772 return bits(a)==0;
3773 }
3774
3775 @Test(dataProvider = "byteTestOpProvider")
3776 static void IS_DEFAULTByteMaxVectorTests(IntFunction<byte[]> fa) {
3777 byte[] a = fa.apply(SPECIES.length());
3778
3779 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3780 for (int i = 0; i < a.length; i += SPECIES.length()) {
3781 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3782 VectorMask<Byte> mv = av.test(VectorOperators.IS_DEFAULT);
3783
3784 // Check results as part of computation.
3785 for (int j = 0; j < SPECIES.length(); j++) {
3786 Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3787 }
3788 }
3789 }
3790 }
3791
3792 @Test(dataProvider = "byteTestOpMaskProvider")
3793 static void IS_DEFAULTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
3794 IntFunction<boolean[]> fm) {
3795 byte[] a = fa.apply(SPECIES.length());
3796 boolean[] mask = fm.apply(SPECIES.length());
3797 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3798
3799 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3800 for (int i = 0; i < a.length; i += SPECIES.length()) {
3801 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3802 VectorMask<Byte> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3803
3804 // Check results as part of computation.
3805 for (int j = 0; j < SPECIES.length(); j++) {
3806 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3807 }
3808 }
3809 }
3810 }
3811
3812 static boolean testIS_NEGATIVE(byte a) {
3813 return bits(a)<0;
3814 }
3815
3816 @Test(dataProvider = "byteTestOpProvider")
3817 static void IS_NEGATIVEByteMaxVectorTests(IntFunction<byte[]> fa) {
3818 byte[] a = fa.apply(SPECIES.length());
3819
3820 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3821 for (int i = 0; i < a.length; i += SPECIES.length()) {
3822 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3823 VectorMask<Byte> mv = av.test(VectorOperators.IS_NEGATIVE);
3824
3825 // Check results as part of computation.
3826 for (int j = 0; j < SPECIES.length(); j++) {
3827 Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3828 }
3829 }
3830 }
3831 }
3833 @Test(dataProvider = "byteTestOpMaskProvider")
3834 static void IS_NEGATIVEMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
3835 IntFunction<boolean[]> fm) {
3836 byte[] a = fa.apply(SPECIES.length());
3837 boolean[] mask = fm.apply(SPECIES.length());
3838 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3839
3840 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3841 for (int i = 0; i < a.length; i += SPECIES.length()) {
3842 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3843 VectorMask<Byte> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3844
3845 // Check results as part of computation.
3846 for (int j = 0; j < SPECIES.length(); j++) {
3847 Assert.assertEquals(mv.laneIsSet(j), vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3848 }
3849 }
3850 }
3851 }
3852
3853 @Test(dataProvider = "byteCompareOpProvider")
3854 static void LTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3855 byte[] a = fa.apply(SPECIES.length());
3856 byte[] b = fb.apply(SPECIES.length());
3857
3858 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3859 for (int i = 0; i < a.length; i += SPECIES.length()) {
3860 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3861 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3862 VectorMask<Byte> mv = av.compare(VectorOperators.LT, bv);
3863
3864 // Check results as part of computation.
3865 for (int j = 0; j < SPECIES.length(); j++) {
3866 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3867 }
3868 }
3869 }
3870 }
3871
3872 @Test(dataProvider = "byteCompareOpProvider")
3873 static void ltByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3874 byte[] a = fa.apply(SPECIES.length());
3875 byte[] b = fb.apply(SPECIES.length());
3876
3877 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3878 for (int i = 0; i < a.length; i += SPECIES.length()) {
3879 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3880 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3881 VectorMask<Byte> mv = av.lt(bv);
3882
3883 // Check results as part of computation.
3884 for (int j = 0; j < SPECIES.length(); j++) {
3885 Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3886 }
3887 }
3888 }
3889 }
3890
3891 @Test(dataProvider = "byteCompareOpMaskProvider")
3894 byte[] a = fa.apply(SPECIES.length());
3895 byte[] b = fb.apply(SPECIES.length());
3896 boolean[] mask = fm.apply(SPECIES.length());
3897
3898 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3899
3900 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3901 for (int i = 0; i < a.length; i += SPECIES.length()) {
3902 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3903 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3904 VectorMask<Byte> mv = av.compare(VectorOperators.LT, bv, vmask);
3905
3906 // Check results as part of computation.
3907 for (int j = 0; j < SPECIES.length(); j++) {
3908 Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3909 }
3910 }
3911 }
3912 }
3913
3914 @Test(dataProvider = "byteCompareOpProvider")
3915 static void GTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3916 byte[] a = fa.apply(SPECIES.length());
3917 byte[] b = fb.apply(SPECIES.length());
3918
3919 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3920 for (int i = 0; i < a.length; i += SPECIES.length()) {
3921 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3922 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3923 VectorMask<Byte> mv = av.compare(VectorOperators.GT, bv);
3924
3925 // Check results as part of computation.
3926 for (int j = 0; j < SPECIES.length(); j++) {
3927 Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3928 }
3929 }
3930 }
3931 }
3932
3933 @Test(dataProvider = "byteCompareOpMaskProvider")
3936 byte[] a = fa.apply(SPECIES.length());
3937 byte[] b = fb.apply(SPECIES.length());
3938 boolean[] mask = fm.apply(SPECIES.length());
3939
3940 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3941
3942 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3943 for (int i = 0; i < a.length; i += SPECIES.length()) {
3944 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3945 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3946 VectorMask<Byte> mv = av.compare(VectorOperators.GT, bv, vmask);
3947
3948 // Check results as part of computation.
3949 for (int j = 0; j < SPECIES.length(); j++) {
3950 Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
3951 }
3952 }
3953 }
3954 }
3955
3956 @Test(dataProvider = "byteCompareOpProvider")
3957 static void EQByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3958 byte[] a = fa.apply(SPECIES.length());
3959 byte[] b = fb.apply(SPECIES.length());
3960
3961 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3962 for (int i = 0; i < a.length; i += SPECIES.length()) {
3963 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3964 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3965 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, bv);
3966
3967 // Check results as part of computation.
3968 for (int j = 0; j < SPECIES.length(); j++) {
3969 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3970 }
3971 }
3972 }
3973 }
3974
3975 @Test(dataProvider = "byteCompareOpProvider")
3976 static void eqByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
3977 byte[] a = fa.apply(SPECIES.length());
3978 byte[] b = fb.apply(SPECIES.length());
3979
3980 for (int ic = 0; ic < INVOC_COUNT; ic++) {
3981 for (int i = 0; i < a.length; i += SPECIES.length()) {
3982 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
3983 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
3984 VectorMask<Byte> mv = av.eq(bv);
3985
3986 // Check results as part of computation.
3987 for (int j = 0; j < SPECIES.length(); j++) {
3988 Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3989 }
3990 }
3991 }
3992 }
3993
3994 @Test(dataProvider = "byteCompareOpMaskProvider")
3997 byte[] a = fa.apply(SPECIES.length());
3998 byte[] b = fb.apply(SPECIES.length());
3999 boolean[] mask = fm.apply(SPECIES.length());
4000
4001 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4002
4003 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4004 for (int i = 0; i < a.length; i += SPECIES.length()) {
4005 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4006 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4007 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, bv, vmask);
4008
4009 // Check results as part of computation.
4010 for (int j = 0; j < SPECIES.length(); j++) {
4011 Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
4012 }
4013 }
4014 }
4015 }
4016
4017 @Test(dataProvider = "byteCompareOpProvider")
4018 static void NEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4019 byte[] a = fa.apply(SPECIES.length());
4020 byte[] b = fb.apply(SPECIES.length());
4021
4022 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4023 for (int i = 0; i < a.length; i += SPECIES.length()) {
4024 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4025 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4026 VectorMask<Byte> mv = av.compare(VectorOperators.NE, bv);
4027
4028 // Check results as part of computation.
4029 for (int j = 0; j < SPECIES.length(); j++) {
4030 Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
4031 }
4032 }
4033 }
4034 }
4035
4036 @Test(dataProvider = "byteCompareOpMaskProvider")
4039 byte[] a = fa.apply(SPECIES.length());
4040 byte[] b = fb.apply(SPECIES.length());
4041 boolean[] mask = fm.apply(SPECIES.length());
4042
4043 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4044
4045 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4046 for (int i = 0; i < a.length; i += SPECIES.length()) {
4047 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4048 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4049 VectorMask<Byte> mv = av.compare(VectorOperators.NE, bv, vmask);
4050
4051 // Check results as part of computation.
4052 for (int j = 0; j < SPECIES.length(); j++) {
4053 Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
4054 }
4055 }
4056 }
4057 }
4058
4059 @Test(dataProvider = "byteCompareOpProvider")
4060 static void LEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4061 byte[] a = fa.apply(SPECIES.length());
4062 byte[] b = fb.apply(SPECIES.length());
4063
4064 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4065 for (int i = 0; i < a.length; i += SPECIES.length()) {
4066 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4067 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4068 VectorMask<Byte> mv = av.compare(VectorOperators.LE, bv);
4069
4070 // Check results as part of computation.
4071 for (int j = 0; j < SPECIES.length(); j++) {
4072 Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
4073 }
4074 }
4075 }
4076 }
4077
4078 @Test(dataProvider = "byteCompareOpMaskProvider")
4081 byte[] a = fa.apply(SPECIES.length());
4082 byte[] b = fb.apply(SPECIES.length());
4083 boolean[] mask = fm.apply(SPECIES.length());
4084
4085 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4086
4087 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4088 for (int i = 0; i < a.length; i += SPECIES.length()) {
4089 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4090 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4091 VectorMask<Byte> mv = av.compare(VectorOperators.LE, bv, vmask);
4092
4093 // Check results as part of computation.
4094 for (int j = 0; j < SPECIES.length(); j++) {
4095 Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
4096 }
4097 }
4098 }
4099 }
4100
4101 @Test(dataProvider = "byteCompareOpProvider")
4102 static void GEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4103 byte[] a = fa.apply(SPECIES.length());
4104 byte[] b = fb.apply(SPECIES.length());
4105
4106 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4107 for (int i = 0; i < a.length; i += SPECIES.length()) {
4108 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4109 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4110 VectorMask<Byte> mv = av.compare(VectorOperators.GE, bv);
4111
4112 // Check results as part of computation.
4113 for (int j = 0; j < SPECIES.length(); j++) {
4114 Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
4115 }
4116 }
4117 }
4118 }
4119
4120 @Test(dataProvider = "byteCompareOpMaskProvider")
4123 byte[] a = fa.apply(SPECIES.length());
4124 byte[] b = fb.apply(SPECIES.length());
4125 boolean[] mask = fm.apply(SPECIES.length());
4126
4127 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4128
4129 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4130 for (int i = 0; i < a.length; i += SPECIES.length()) {
4131 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4132 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4133 VectorMask<Byte> mv = av.compare(VectorOperators.GE, bv, vmask);
4134
4135 // Check results as part of computation.
4136 for (int j = 0; j < SPECIES.length(); j++) {
4137 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
4138 }
4139 }
4140 }
4141 }
4142
4143 @Test(dataProvider = "byteCompareOpProvider")
4144 static void UNSIGNED_LTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4145 byte[] a = fa.apply(SPECIES.length());
4146 byte[] b = fb.apply(SPECIES.length());
4147
4148 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4149 for (int i = 0; i < a.length; i += SPECIES.length()) {
4150 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4151 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4152 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
4153
4154 // Check results as part of computation.
4155 for (int j = 0; j < SPECIES.length(); j++) {
4156 Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
4157 }
4158 }
4159 }
4160 }
4161
4162 @Test(dataProvider = "byteCompareOpMaskProvider")
4163 static void UNSIGNED_LTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4164 IntFunction<boolean[]> fm) {
4165 byte[] a = fa.apply(SPECIES.length());
4166 byte[] b = fb.apply(SPECIES.length());
4167 boolean[] mask = fm.apply(SPECIES.length());
4168
4169 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4170
4171 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4172 for (int i = 0; i < a.length; i += SPECIES.length()) {
4173 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4174 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4175 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
4176
4177 // Check results as part of computation.
4178 for (int j = 0; j < SPECIES.length(); j++) {
4179 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
4180 }
4181 }
4182 }
4183 }
4184
4185 @Test(dataProvider = "byteCompareOpProvider")
4186 static void UNSIGNED_GTByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4187 byte[] a = fa.apply(SPECIES.length());
4188 byte[] b = fb.apply(SPECIES.length());
4189
4190 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4191 for (int i = 0; i < a.length; i += SPECIES.length()) {
4192 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4193 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4194 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
4195
4196 // Check results as part of computation.
4197 for (int j = 0; j < SPECIES.length(); j++) {
4198 Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
4199 }
4200 }
4201 }
4202 }
4203
4204 @Test(dataProvider = "byteCompareOpMaskProvider")
4205 static void UNSIGNED_GTByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4206 IntFunction<boolean[]> fm) {
4207 byte[] a = fa.apply(SPECIES.length());
4208 byte[] b = fb.apply(SPECIES.length());
4209 boolean[] mask = fm.apply(SPECIES.length());
4210
4211 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4212
4213 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4214 for (int i = 0; i < a.length; i += SPECIES.length()) {
4215 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4216 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4217 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
4218
4219 // Check results as part of computation.
4220 for (int j = 0; j < SPECIES.length(); j++) {
4221 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
4222 }
4223 }
4224 }
4225 }
4226
4227 @Test(dataProvider = "byteCompareOpProvider")
4228 static void UNSIGNED_LEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4229 byte[] a = fa.apply(SPECIES.length());
4230 byte[] b = fb.apply(SPECIES.length());
4231
4232 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4233 for (int i = 0; i < a.length; i += SPECIES.length()) {
4234 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4235 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4236 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
4237
4238 // Check results as part of computation.
4239 for (int j = 0; j < SPECIES.length(); j++) {
4240 Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
4241 }
4242 }
4243 }
4244 }
4245
4246 @Test(dataProvider = "byteCompareOpMaskProvider")
4247 static void UNSIGNED_LEByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4248 IntFunction<boolean[]> fm) {
4249 byte[] a = fa.apply(SPECIES.length());
4250 byte[] b = fb.apply(SPECIES.length());
4251 boolean[] mask = fm.apply(SPECIES.length());
4252
4253 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4254
4255 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4256 for (int i = 0; i < a.length; i += SPECIES.length()) {
4257 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4258 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4259 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
4260
4261 // Check results as part of computation.
4262 for (int j = 0; j < SPECIES.length(); j++) {
4263 Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
4264 }
4265 }
4266 }
4267 }
4268
4269 @Test(dataProvider = "byteCompareOpProvider")
4270 static void UNSIGNED_GEByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4271 byte[] a = fa.apply(SPECIES.length());
4272 byte[] b = fb.apply(SPECIES.length());
4273
4274 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4275 for (int i = 0; i < a.length; i += SPECIES.length()) {
4276 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4277 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4278 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
4279
4280 // Check results as part of computation.
4281 for (int j = 0; j < SPECIES.length(); j++) {
4282 Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
4283 }
4284 }
4285 }
4286 }
4287
4288 @Test(dataProvider = "byteCompareOpMaskProvider")
4289 static void UNSIGNED_GEByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4290 IntFunction<boolean[]> fm) {
4291 byte[] a = fa.apply(SPECIES.length());
4292 byte[] b = fb.apply(SPECIES.length());
4293 boolean[] mask = fm.apply(SPECIES.length());
4294
4295 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4296
4297 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4298 for (int i = 0; i < a.length; i += SPECIES.length()) {
4299 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4300 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4301 VectorMask<Byte> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
4302
4303 // Check results as part of computation.
4304 for (int j = 0; j < SPECIES.length(); j++) {
4305 Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
4306 }
4307 }
4308 }
4309 }
4310
4311 @Test(dataProvider = "byteCompareOpProvider")
4312 static void LTByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4313 byte[] a = fa.apply(SPECIES.length());
4314 byte[] b = fb.apply(SPECIES.length());
4315
4316 for (int i = 0; i < a.length; i += SPECIES.length()) {
4317 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4318 VectorMask<Byte> mv = av.compare(VectorOperators.LT, b[i]);
4319
4320 // Check results as part of computation.
4321 for (int j = 0; j < SPECIES.length(); j++) {
4322 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4323 }
4324 }
4325 }
4326
4327 @Test(dataProvider = "byteCompareOpMaskProvider")
4328 static void LTByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa,
4329 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
4330 byte[] a = fa.apply(SPECIES.length());
4331 byte[] b = fb.apply(SPECIES.length());
4332 boolean[] mask = fm.apply(SPECIES.length());
4333
4334 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4335
4336 for (int i = 0; i < a.length; i += SPECIES.length()) {
4337 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4338 VectorMask<Byte> mv = av.compare(VectorOperators.LT, b[i], vmask);
4339
4340 // Check results as part of computation.
4341 for (int j = 0; j < SPECIES.length(); j++) {
4342 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
4343 }
4344 }
4345 }
4346
4347 @Test(dataProvider = "byteCompareOpProvider")
4348 static void LTByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4349 byte[] a = fa.apply(SPECIES.length());
4350 byte[] b = fb.apply(SPECIES.length());
4351
4352 for (int i = 0; i < a.length; i += SPECIES.length()) {
4353 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4354 VectorMask<Byte> mv = av.compare(VectorOperators.LT, (long)b[i]);
4355
4356 // Check results as part of computation.
4357 for (int j = 0; j < SPECIES.length(); j++) {
4358 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (byte)((long)b[i]));
4359 }
4360 }
4361 }
4362
4363 @Test(dataProvider = "byteCompareOpMaskProvider")
4364 static void LTByteMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<byte[]> fa,
4365 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
4366 byte[] a = fa.apply(SPECIES.length());
4367 byte[] b = fb.apply(SPECIES.length());
4368 boolean[] mask = fm.apply(SPECIES.length());
4369
4370 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4371
4372 for (int i = 0; i < a.length; i += SPECIES.length()) {
4373 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4374 VectorMask<Byte> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
4375
4376 // Check results as part of computation.
4377 for (int j = 0; j < SPECIES.length(); j++) {
4378 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (byte)((long)b[i])));
4379 }
4380 }
4381 }
4382
4383 @Test(dataProvider = "byteCompareOpProvider")
4384 static void EQByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4385 byte[] a = fa.apply(SPECIES.length());
4386 byte[] b = fb.apply(SPECIES.length());
4387
4388 for (int i = 0; i < a.length; i += SPECIES.length()) {
4389 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4390 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, b[i]);
4391
4392 // Check results as part of computation.
4393 for (int j = 0; j < SPECIES.length(); j++) {
4394 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4395 }
4396 }
4397 }
4398
4399 @Test(dataProvider = "byteCompareOpMaskProvider")
4400 static void EQByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa,
4401 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
4402 byte[] a = fa.apply(SPECIES.length());
4403 byte[] b = fb.apply(SPECIES.length());
4404 boolean[] mask = fm.apply(SPECIES.length());
4405
4406 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4407
4408 for (int i = 0; i < a.length; i += SPECIES.length()) {
4409 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4410 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, b[i], vmask);
4411
4412 // Check results as part of computation.
4413 for (int j = 0; j < SPECIES.length(); j++) {
4414 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
4415 }
4416 }
4417 }
4418
4419 @Test(dataProvider = "byteCompareOpProvider")
4420 static void EQByteMaxVectorTestsBroadcastLongSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4421 byte[] a = fa.apply(SPECIES.length());
4422 byte[] b = fb.apply(SPECIES.length());
4423
4424 for (int i = 0; i < a.length; i += SPECIES.length()) {
4425 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4426 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, (long)b[i]);
4427
4428 // Check results as part of computation.
4429 for (int j = 0; j < SPECIES.length(); j++) {
4430 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (byte)((long)b[i]));
4431 }
4432 }
4433 }
4434
4435 @Test(dataProvider = "byteCompareOpMaskProvider")
4436 static void EQByteMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<byte[]> fa,
4437 IntFunction<byte[]> fb, IntFunction<boolean[]> fm) {
4438 byte[] a = fa.apply(SPECIES.length());
4439 byte[] b = fb.apply(SPECIES.length());
4440 boolean[] mask = fm.apply(SPECIES.length());
4441
4442 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4443
4444 for (int i = 0; i < a.length; i += SPECIES.length()) {
4445 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4446 VectorMask<Byte> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
4447
4448 // Check results as part of computation.
4449 for (int j = 0; j < SPECIES.length(); j++) {
4450 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (byte)((long)b[i])));
4451 }
4452 }
4453 }
4454
4493 assertRearrangeArraysEquals(r, a, order, SPECIES.length());
4494 }
4495
4496 @Test(dataProvider = "byteUnaryOpShuffleMaskProvider")
4497 static void RearrangeByteMaxVectorTestsMaskedSmokeTest(IntFunction<byte[]> fa,
4498 BiFunction<Integer,Integer,int[]> fs,
4499 IntFunction<boolean[]> fm) {
4500 byte[] a = fa.apply(SPECIES.length());
4501 int[] order = fs.apply(a.length, SPECIES.length());
4502 byte[] r = fr.apply(SPECIES.length());
4503 boolean[] mask = fm.apply(SPECIES.length());
4504 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4505
4506 for (int i = 0; i < a.length; i += SPECIES.length()) {
4507 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4508 av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
4509 }
4510
4511 assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
4512 }
4513
4514 @Test(dataProvider = "byteUnaryOpMaskProvider")
4515 static void compressByteMaxVectorTests(IntFunction<byte[]> fa,
4516 IntFunction<boolean[]> fm) {
4517 byte[] a = fa.apply(SPECIES.length());
4518 byte[] r = fr.apply(SPECIES.length());
4519 boolean[] mask = fm.apply(SPECIES.length());
4520 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4521
4522 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4523 for (int i = 0; i < a.length; i += SPECIES.length()) {
4524 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4525 av.compress(vmask).intoArray(r, i);
4526 }
4527 }
4528
4529 assertcompressArraysEquals(r, a, mask, SPECIES.length());
4530 }
4531
4532 @Test(dataProvider = "byteUnaryOpMaskProvider")
4533 static void expandByteMaxVectorTests(IntFunction<byte[]> fa,
4534 IntFunction<boolean[]> fm) {
4535 byte[] a = fa.apply(SPECIES.length());
4536 byte[] r = fr.apply(SPECIES.length());
4537 boolean[] mask = fm.apply(SPECIES.length());
4538 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4539
4540 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4541 for (int i = 0; i < a.length; i += SPECIES.length()) {
4542 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4543 av.expand(vmask).intoArray(r, i);
4544 }
4545 }
4546
4547 assertexpandArraysEquals(r, a, mask, SPECIES.length());
4548 }
4549
4550 @Test(dataProvider = "byteUnaryOpProvider")
4551 static void getByteMaxVectorTests(IntFunction<byte[]> fa) {
4552 byte[] a = fa.apply(SPECIES.length());
4553 byte[] r = fr.apply(SPECIES.length());
4554
4555 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4556 for (int i = 0; i < a.length; i += SPECIES.length()) {
4557 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4558 int num_lanes = SPECIES.length();
4559 // Manually unroll because full unroll happens after intrinsification.
4560 // Unroll is needed because get intrinsic requires for index to be a known constant.
4561 if (num_lanes == 1) {
4562 r[i]=av.lane(0);
4563 } else if (num_lanes == 2) {
4564 r[i]=av.lane(0);
4565 r[i+1]=av.lane(1);
4566 } else if (num_lanes == 4) {
4567 r[i]=av.lane(0);
4568 r[i+1]=av.lane(1);
4569 r[i+2]=av.lane(2);
4700 }
4701 }
4702
4703 assertArraysEquals(r, a, ByteMaxVectorTests::get);
4704 }
4705
4706 @Test(dataProvider = "byteUnaryOpProvider")
4707 static void BroadcastByteMaxVectorTests(IntFunction<byte[]> fa) {
4708 byte[] a = fa.apply(SPECIES.length());
4709 byte[] r = new byte[a.length];
4710
4711 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4712 for (int i = 0; i < a.length; i += SPECIES.length()) {
4713 ByteVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4714 }
4715 }
4716
4717 assertBroadcastArraysEquals(r, a);
4718 }
4719
4720 @Test(dataProvider = "byteUnaryOpProvider")
4721 static void ZeroByteMaxVectorTests(IntFunction<byte[]> fa) {
4722 byte[] a = fa.apply(SPECIES.length());
4723 byte[] r = new byte[a.length];
4724
4725 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4726 for (int i = 0; i < a.length; i += SPECIES.length()) {
4727 ByteVector.zero(SPECIES).intoArray(a, i);
4728 }
4729 }
4730
4731 Assert.assertEquals(a, r);
4732 }
4733
4734 static byte[] sliceUnary(byte[] a, int origin, int idx) {
4735 byte[] res = new byte[SPECIES.length()];
4736 for (int i = 0; i < SPECIES.length(); i++){
4737 if(i+origin < SPECIES.length())
4738 res[i] = a[idx+i+origin];
4739 else
4740 res[i] = (byte)0;
4741 }
4742 return res;
4743 }
4744
4745 @Test(dataProvider = "byteUnaryOpProvider")
4746 static void sliceUnaryByteMaxVectorTests(IntFunction<byte[]> fa) {
4747 byte[] a = fa.apply(SPECIES.length());
4748 byte[] r = new byte[a.length];
4749 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4750 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4751 for (int i = 0; i < a.length; i += SPECIES.length()) {
4752 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4753 av.slice(origin).intoArray(r, i);
4754 }
4755 }
4756
4757 assertArraysEquals(r, a, origin, ByteMaxVectorTests::sliceUnary);
4758 }
4759
4760 static byte[] sliceBinary(byte[] a, byte[] b, int origin, int idx) {
4761 byte[] res = new byte[SPECIES.length()];
4762 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4763 if(i+origin < SPECIES.length())
4764 res[i] = a[idx+i+origin];
4765 else {
4766 res[i] = b[idx+j];
4767 j++;
4768 }
4769 }
4770 return res;
4771 }
4772
4773 @Test(dataProvider = "byteBinaryOpProvider")
4774 static void sliceBinaryByteMaxVectorTestsBinary(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4775 byte[] a = fa.apply(SPECIES.length());
4776 byte[] b = fb.apply(SPECIES.length());
4777 byte[] r = new byte[a.length];
4778 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4779 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4780 for (int i = 0; i < a.length; i += SPECIES.length()) {
4781 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4782 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4783 av.slice(origin, bv).intoArray(r, i);
4784 }
4785 }
4786
4787 assertArraysEquals(r, a, b, origin, ByteMaxVectorTests::sliceBinary);
4788 }
4789
4790 static byte[] slice(byte[] a, byte[] b, int origin, boolean[] mask, int idx) {
4791 byte[] res = new byte[SPECIES.length()];
4792 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4793 if(i+origin < SPECIES.length())
4794 res[i] = mask[i] ? a[idx+i+origin] : (byte)0;
4795 else {
4796 res[i] = mask[i] ? b[idx+j] : (byte)0;
4797 j++;
4798 }
4799 }
4800 return res;
4801 }
4802
4803 @Test(dataProvider = "byteBinaryOpMaskProvider")
4804 static void sliceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4805 IntFunction<boolean[]> fm) {
4806 byte[] a = fa.apply(SPECIES.length());
4807 byte[] b = fb.apply(SPECIES.length());
4808 boolean[] mask = fm.apply(SPECIES.length());
4809 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4810
4811 byte[] r = new byte[a.length];
4812 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4813 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4814 for (int i = 0; i < a.length; i += SPECIES.length()) {
4815 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4816 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4817 av.slice(origin, bv, vmask).intoArray(r, i);
4818 }
4819 }
4820
4821 assertArraysEquals(r, a, b, origin, mask, ByteMaxVectorTests::slice);
4822 }
4823
4824 static byte[] unsliceUnary(byte[] a, int origin, int idx) {
4825 byte[] res = new byte[SPECIES.length()];
4826 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4827 if(i < origin)
4828 res[i] = (byte)0;
4829 else {
4830 res[i] = a[idx+j];
4831 j++;
4832 }
4833 }
4834 return res;
4835 }
4836
4837 @Test(dataProvider = "byteUnaryOpProvider")
4838 static void unsliceUnaryByteMaxVectorTests(IntFunction<byte[]> fa) {
4839 byte[] a = fa.apply(SPECIES.length());
4840 byte[] r = new byte[a.length];
4841 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4842 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4843 for (int i = 0; i < a.length; i += SPECIES.length()) {
4844 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4845 av.unslice(origin).intoArray(r, i);
4846 }
4847 }
4848
4849 assertArraysEquals(r, a, origin, ByteMaxVectorTests::unsliceUnary);
4850 }
4851
4852 static byte[] unsliceBinary(byte[] a, byte[] b, int origin, int part, int idx) {
4853 byte[] res = new byte[SPECIES.length()];
4854 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4855 if (part == 0) {
4856 if (i < origin)
4857 res[i] = b[idx+i];
4858 else {
4859 res[i] = a[idx+j];
4860 j++;
4861 }
4862 } else if (part == 1) {
4863 if (i < origin)
4864 res[i] = a[idx+SPECIES.length()-origin+i];
4865 else {
4866 res[i] = b[idx+origin+j];
4867 j++;
4868 }
4869 }
4870 }
4871 return res;
4872 }
4873
4874 @Test(dataProvider = "byteBinaryOpProvider")
4875 static void unsliceBinaryByteMaxVectorTestsBinary(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
4876 byte[] a = fa.apply(SPECIES.length());
4877 byte[] b = fb.apply(SPECIES.length());
4878 byte[] r = new byte[a.length];
4879 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4880 int part = (new java.util.Random()).nextInt(2);
4881 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4882 for (int i = 0; i < a.length; i += SPECIES.length()) {
4883 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4884 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4885 av.unslice(origin, bv, part).intoArray(r, i);
4886 }
4887 }
4888
4889 assertArraysEquals(r, a, b, origin, part, ByteMaxVectorTests::unsliceBinary);
4890 }
4891
4892 static byte[] unslice(byte[] a, byte[] b, int origin, int part, boolean[] mask, int idx) {
4893 byte[] res = new byte[SPECIES.length()];
4894 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4895 if(i+origin < SPECIES.length())
4896 res[i] = b[idx+i+origin];
4897 else {
4898 res[i] = b[idx+j];
4899 j++;
4900 }
4901 }
4902 for (int i = 0; i < SPECIES.length(); i++){
4903 res[i] = mask[i] ? a[idx+i] : res[i];
4904 }
4905 byte[] res1 = new byte[SPECIES.length()];
4906 if (part == 0) {
4907 for (int i = 0, j = 0; i < SPECIES.length(); i++){
4908 if (i < origin)
4909 res1[i] = b[idx+i];
4910 else {
4911 res1[i] = res[j];
4929 static void unsliceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4930 IntFunction<boolean[]> fm) {
4931 byte[] a = fa.apply(SPECIES.length());
4932 byte[] b = fb.apply(SPECIES.length());
4933 boolean[] mask = fm.apply(SPECIES.length());
4934 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4935 byte[] r = new byte[a.length];
4936 int origin = (new java.util.Random()).nextInt(SPECIES.length());
4937 int part = (new java.util.Random()).nextInt(2);
4938 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4939 for (int i = 0; i < a.length; i += SPECIES.length()) {
4940 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4941 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4942 av.unslice(origin, bv, part, vmask).intoArray(r, i);
4943 }
4944 }
4945
4946 assertArraysEquals(r, a, b, origin, part, mask, ByteMaxVectorTests::unslice);
4947 }
4948
4949 static byte BITWISE_BLEND(byte a, byte b, byte c) {
4950 return (byte)((a&~(c))|(b&c));
4951 }
4952
4953 static byte bitwiseBlend(byte a, byte b, byte c) {
4954 return (byte)((a&~(c))|(b&c));
4955 }
4956
4957 @Test(dataProvider = "byteTernaryOpProvider")
4958 static void BITWISE_BLENDByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
4959 byte[] a = fa.apply(SPECIES.length());
4960 byte[] b = fb.apply(SPECIES.length());
4961 byte[] c = fc.apply(SPECIES.length());
4962 byte[] r = fr.apply(SPECIES.length());
4963
4964 for (int ic = 0; ic < INVOC_COUNT; ic++) {
4965 for (int i = 0; i < a.length; i += SPECIES.length()) {
4966 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4967 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4968 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
4969 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
4970 }
4971 }
4972
4973 assertArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
4974 }
4975
4976 @Test(dataProvider = "byteTernaryOpProvider")
4977 static void bitwiseBlendByteMaxVectorTests(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
4978 byte[] a = fa.apply(SPECIES.length());
4979 byte[] b = fb.apply(SPECIES.length());
4980 byte[] c = fc.apply(SPECIES.length());
4981 byte[] r = fr.apply(SPECIES.length());
4982
4983 for (int i = 0; i < a.length; i += SPECIES.length()) {
4984 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
4985 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
4986 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
4987 av.bitwiseBlend(bv, cv).intoArray(r, i);
4988 }
4989
4990 assertArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
4991 }
4992
4993 @Test(dataProvider = "byteTernaryOpMaskProvider")
4994 static void BITWISE_BLENDByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
4995 IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
4996 byte[] a = fa.apply(SPECIES.length());
4997 byte[] b = fb.apply(SPECIES.length());
4998 byte[] c = fc.apply(SPECIES.length());
4999 byte[] r = fr.apply(SPECIES.length());
5000 boolean[] mask = fm.apply(SPECIES.length());
5001 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5002
5003 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5004 for (int i = 0; i < a.length; i += SPECIES.length()) {
5005 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5006 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5007 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5008 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
5009 }
5010 }
5011
5012 assertArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5013 }
5014
5015 @Test(dataProvider = "byteTernaryOpProvider")
5016 static void BITWISE_BLENDByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5017 byte[] a = fa.apply(SPECIES.length());
5018 byte[] b = fb.apply(SPECIES.length());
5019 byte[] c = fc.apply(SPECIES.length());
5020 byte[] r = fr.apply(SPECIES.length());
5021
5022 for (int i = 0; i < a.length; i += SPECIES.length()) {
5023 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5024 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5025 av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
5026 }
5027 assertBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
5028 }
5029
5030 @Test(dataProvider = "byteTernaryOpProvider")
5031 static void BITWISE_BLENDByteMaxVectorTestsAltBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5032 byte[] a = fa.apply(SPECIES.length());
5033 byte[] b = fb.apply(SPECIES.length());
5034 byte[] c = fc.apply(SPECIES.length());
5035 byte[] r = fr.apply(SPECIES.length());
5036
5037 for (int i = 0; i < a.length; i += SPECIES.length()) {
5038 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5039 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5040 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
5041 }
5042 assertAltBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
5043 }
5044
5045 @Test(dataProvider = "byteTernaryOpProvider")
5046 static void bitwiseBlendByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5047 byte[] a = fa.apply(SPECIES.length());
5048 byte[] b = fb.apply(SPECIES.length());
5049 byte[] c = fc.apply(SPECIES.length());
5050 byte[] r = fr.apply(SPECIES.length());
5051
5052 for (int i = 0; i < a.length; i += SPECIES.length()) {
5053 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5054 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5055 av.bitwiseBlend(bv, c[i]).intoArray(r, i);
5056 }
5057 assertBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
5058 }
5059
5060 @Test(dataProvider = "byteTernaryOpProvider")
5061 static void bitwiseBlendByteMaxVectorTestsAltBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5062 byte[] a = fa.apply(SPECIES.length());
5063 byte[] b = fb.apply(SPECIES.length());
5064 byte[] c = fc.apply(SPECIES.length());
5065 byte[] r = fr.apply(SPECIES.length());
5066
5067 for (int i = 0; i < a.length; i += SPECIES.length()) {
5068 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5069 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5070 av.bitwiseBlend(b[i], cv).intoArray(r, i);
5071 }
5072 assertAltBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
5073 }
5074
5075 @Test(dataProvider = "byteTernaryOpMaskProvider")
5076 static void BITWISE_BLENDByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5077 IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
5078 byte[] a = fa.apply(SPECIES.length());
5079 byte[] b = fb.apply(SPECIES.length());
5080 byte[] c = fc.apply(SPECIES.length());
5081 byte[] r = fr.apply(SPECIES.length());
5082 boolean[] mask = fm.apply(SPECIES.length());
5083 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5084
5085 for (int i = 0; i < a.length; i += SPECIES.length()) {
5086 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5087 ByteVector bv = ByteVector.fromArray(SPECIES, b, i);
5088 av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
5089 }
5090
5091 assertBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5092 }
5093
5094 @Test(dataProvider = "byteTernaryOpMaskProvider")
5095 static void BITWISE_BLENDByteMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5096 IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
5097 byte[] a = fa.apply(SPECIES.length());
5098 byte[] b = fb.apply(SPECIES.length());
5099 byte[] c = fc.apply(SPECIES.length());
5100 byte[] r = fr.apply(SPECIES.length());
5101 boolean[] mask = fm.apply(SPECIES.length());
5102 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5103
5104 for (int i = 0; i < a.length; i += SPECIES.length()) {
5105 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5106 ByteVector cv = ByteVector.fromArray(SPECIES, c, i);
5107 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
5108 }
5109
5110 assertAltBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5111 }
5112
5113 @Test(dataProvider = "byteTernaryOpProvider")
5114 static void BITWISE_BLENDByteMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5115 byte[] a = fa.apply(SPECIES.length());
5116 byte[] b = fb.apply(SPECIES.length());
5117 byte[] c = fc.apply(SPECIES.length());
5118 byte[] r = fr.apply(SPECIES.length());
5119
5120 for (int i = 0; i < a.length; i += SPECIES.length()) {
5121 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5122 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
5123 }
5124
5125 assertDoubleBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::BITWISE_BLEND);
5126 }
5127
5128 @Test(dataProvider = "byteTernaryOpProvider")
5129 static void bitwiseBlendByteMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb, IntFunction<byte[]> fc) {
5130 byte[] a = fa.apply(SPECIES.length());
5131 byte[] b = fb.apply(SPECIES.length());
5132 byte[] c = fc.apply(SPECIES.length());
5133 byte[] r = fr.apply(SPECIES.length());
5134
5135 for (int i = 0; i < a.length; i += SPECIES.length()) {
5136 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5137 av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
5138 }
5139
5140 assertDoubleBroadcastArraysEquals(r, a, b, c, ByteMaxVectorTests::bitwiseBlend);
5141 }
5142
5143 @Test(dataProvider = "byteTernaryOpMaskProvider")
5144 static void BITWISE_BLENDByteMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb,
5145 IntFunction<byte[]> fc, IntFunction<boolean[]> fm) {
5146 byte[] a = fa.apply(SPECIES.length());
5147 byte[] b = fb.apply(SPECIES.length());
5148 byte[] c = fc.apply(SPECIES.length());
5149 byte[] r = fr.apply(SPECIES.length());
5150 boolean[] mask = fm.apply(SPECIES.length());
5151 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5152
5153 for (int i = 0; i < a.length; i += SPECIES.length()) {
5154 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5155 av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
5156 }
5157
5158 assertDoubleBroadcastArraysEquals(r, a, b, c, mask, ByteMaxVectorTests::BITWISE_BLEND);
5159 }
5160
5161 static byte NEG(byte a) {
5162 return (byte)(-((byte)a));
5163 }
5164
5165 static byte neg(byte a) {
5166 return (byte)(-((byte)a));
5167 }
5168
5169 @Test(dataProvider = "byteUnaryOpProvider")
5170 static void NEGByteMaxVectorTests(IntFunction<byte[]> fa) {
5171 byte[] a = fa.apply(SPECIES.length());
5172 byte[] r = fr.apply(SPECIES.length());
5173
5174 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5175 for (int i = 0; i < a.length; i += SPECIES.length()) {
5176 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5177 av.lanewise(VectorOperators.NEG).intoArray(r, i);
5178 }
5179 }
5180
5253 }
5254
5255 @Test(dataProvider = "byteUnaryOpMaskProvider")
5256 static void ABSMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
5257 IntFunction<boolean[]> fm) {
5258 byte[] a = fa.apply(SPECIES.length());
5259 byte[] r = fr.apply(SPECIES.length());
5260 boolean[] mask = fm.apply(SPECIES.length());
5261 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5262
5263 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5264 for (int i = 0; i < a.length; i += SPECIES.length()) {
5265 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5266 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
5267 }
5268 }
5269
5270 assertArraysEquals(r, a, mask, ByteMaxVectorTests::ABS);
5271 }
5272
5273 static byte NOT(byte a) {
5274 return (byte)(~((byte)a));
5275 }
5276
5277 static byte not(byte a) {
5278 return (byte)(~((byte)a));
5279 }
5280
5281 @Test(dataProvider = "byteUnaryOpProvider")
5282 static void NOTByteMaxVectorTests(IntFunction<byte[]> fa) {
5283 byte[] a = fa.apply(SPECIES.length());
5284 byte[] r = fr.apply(SPECIES.length());
5285
5286 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5287 for (int i = 0; i < a.length; i += SPECIES.length()) {
5288 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5289 av.lanewise(VectorOperators.NOT).intoArray(r, i);
5290 }
5291 }
5292
5293 assertArraysEquals(r, a, ByteMaxVectorTests::NOT);
5294 }
5295
5296 @Test(dataProvider = "byteUnaryOpProvider")
5297 static void notByteMaxVectorTests(IntFunction<byte[]> fa) {
5298 byte[] a = fa.apply(SPECIES.length());
5299 byte[] r = fr.apply(SPECIES.length());
5300
5301 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5302 for (int i = 0; i < a.length; i += SPECIES.length()) {
5303 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5304 av.not().intoArray(r, i);
5305 }
5306 }
5307
5308 assertArraysEquals(r, a, ByteMaxVectorTests::not);
5309 }
5310
5311 @Test(dataProvider = "byteUnaryOpMaskProvider")
5312 static void NOTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
5313 IntFunction<boolean[]> fm) {
5314 byte[] a = fa.apply(SPECIES.length());
5315 byte[] r = fr.apply(SPECIES.length());
5316 boolean[] mask = fm.apply(SPECIES.length());
5317 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5318
5319 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5320 for (int i = 0; i < a.length; i += SPECIES.length()) {
5321 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5322 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
5323 }
5324 }
5325
5326 assertArraysEquals(r, a, mask, ByteMaxVectorTests::NOT);
5327 }
5328
5329 static byte ZOMO(byte a) {
5330 return (byte)((a==0?0:-1));
5331 }
5332
5333 @Test(dataProvider = "byteUnaryOpProvider")
5334 static void ZOMOByteMaxVectorTests(IntFunction<byte[]> fa) {
5335 byte[] a = fa.apply(SPECIES.length());
5336 byte[] r = fr.apply(SPECIES.length());
5337
5338 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5339 for (int i = 0; i < a.length; i += SPECIES.length()) {
5340 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5341 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
5342 }
5343 }
5344
5345 assertArraysEquals(r, a, ByteMaxVectorTests::ZOMO);
5346 }
5347
5348 @Test(dataProvider = "byteUnaryOpMaskProvider")
5349 static void ZOMOMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
5350 IntFunction<boolean[]> fm) {
5351 byte[] a = fa.apply(SPECIES.length());
5352 byte[] r = fr.apply(SPECIES.length());
5353 boolean[] mask = fm.apply(SPECIES.length());
5354 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5355
5356 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5357 for (int i = 0; i < a.length; i += SPECIES.length()) {
5358 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5359 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
5360 }
5361 }
5362
5363 assertArraysEquals(r, a, mask, ByteMaxVectorTests::ZOMO);
5364 }
5365
5366 static byte BIT_COUNT(byte a) {
5367 return (byte)(Integer.bitCount((int)a & 0xFF));
5368 }
5369
5370 @Test(dataProvider = "byteUnaryOpProvider")
5371 static void BIT_COUNTByteMaxVectorTests(IntFunction<byte[]> fa) {
5372 byte[] a = fa.apply(SPECIES.length());
5373 byte[] r = fr.apply(SPECIES.length());
5374
5375 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5376 for (int i = 0; i < a.length; i += SPECIES.length()) {
5377 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5378 av.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i);
5379 }
5380 }
5381
5382 assertArraysEquals(r, a, ByteMaxVectorTests::BIT_COUNT);
5383 }
5384
5385 @Test(dataProvider = "byteUnaryOpMaskProvider")
5386 static void BIT_COUNTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
5387 IntFunction<boolean[]> fm) {
5388 byte[] a = fa.apply(SPECIES.length());
5389 byte[] r = fr.apply(SPECIES.length());
5390 boolean[] mask = fm.apply(SPECIES.length());
5391 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5392
5393 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5394 for (int i = 0; i < a.length; i += SPECIES.length()) {
5395 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5396 av.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i);
5397 }
5398 }
5399
5400 assertArraysEquals(r, a, mask, ByteMaxVectorTests::BIT_COUNT);
5401 }
5402
5403 static byte TRAILING_ZEROS_COUNT(byte a) {
5404 return (byte)(TRAILING_ZEROS_COUNT_scalar(a));
5405 }
5406
5407 @Test(dataProvider = "byteUnaryOpProvider")
5408 static void TRAILING_ZEROS_COUNTByteMaxVectorTests(IntFunction<byte[]> fa) {
5409 byte[] a = fa.apply(SPECIES.length());
5410 byte[] r = fr.apply(SPECIES.length());
5411
5412 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5413 for (int i = 0; i < a.length; i += SPECIES.length()) {
5414 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5415 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i);
5416 }
5417 }
5418
5419 assertArraysEquals(r, a, ByteMaxVectorTests::TRAILING_ZEROS_COUNT);
5420 }
5421
5422 @Test(dataProvider = "byteUnaryOpMaskProvider")
5423 static void TRAILING_ZEROS_COUNTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
5424 IntFunction<boolean[]> fm) {
5425 byte[] a = fa.apply(SPECIES.length());
5426 byte[] r = fr.apply(SPECIES.length());
5427 boolean[] mask = fm.apply(SPECIES.length());
5428 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5429
5430 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5431 for (int i = 0; i < a.length; i += SPECIES.length()) {
5432 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5433 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i);
5434 }
5435 }
5436
5437 assertArraysEquals(r, a, mask, ByteMaxVectorTests::TRAILING_ZEROS_COUNT);
5438 }
5439
5440 static byte LEADING_ZEROS_COUNT(byte a) {
5441 return (byte)(LEADING_ZEROS_COUNT_scalar(a));
5442 }
5443
5444 @Test(dataProvider = "byteUnaryOpProvider")
5445 static void LEADING_ZEROS_COUNTByteMaxVectorTests(IntFunction<byte[]> fa) {
5446 byte[] a = fa.apply(SPECIES.length());
5447 byte[] r = fr.apply(SPECIES.length());
5448
5449 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5450 for (int i = 0; i < a.length; i += SPECIES.length()) {
5451 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5452 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i);
5453 }
5454 }
5455
5456 assertArraysEquals(r, a, ByteMaxVectorTests::LEADING_ZEROS_COUNT);
5457 }
5458
5459 @Test(dataProvider = "byteUnaryOpMaskProvider")
5460 static void LEADING_ZEROS_COUNTMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
5461 IntFunction<boolean[]> fm) {
5462 byte[] a = fa.apply(SPECIES.length());
5463 byte[] r = fr.apply(SPECIES.length());
5464 boolean[] mask = fm.apply(SPECIES.length());
5465 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5466
5467 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5468 for (int i = 0; i < a.length; i += SPECIES.length()) {
5469 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5470 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i);
5471 }
5472 }
5473
5474 assertArraysEquals(r, a, mask, ByteMaxVectorTests::LEADING_ZEROS_COUNT);
5475 }
5476
5477 static byte REVERSE(byte a) {
5478 return (byte)(REVERSE_scalar(a));
5479 }
5480
5481 @Test(dataProvider = "byteUnaryOpProvider")
5482 static void REVERSEByteMaxVectorTests(IntFunction<byte[]> fa) {
5483 byte[] a = fa.apply(SPECIES.length());
5484 byte[] r = fr.apply(SPECIES.length());
5485
5486 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5487 for (int i = 0; i < a.length; i += SPECIES.length()) {
5488 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5489 av.lanewise(VectorOperators.REVERSE).intoArray(r, i);
5490 }
5491 }
5492
5493 assertArraysEquals(r, a, ByteMaxVectorTests::REVERSE);
5494 }
5495
5496 @Test(dataProvider = "byteUnaryOpMaskProvider")
5497 static void REVERSEMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
5498 IntFunction<boolean[]> fm) {
5499 byte[] a = fa.apply(SPECIES.length());
5500 byte[] r = fr.apply(SPECIES.length());
5501 boolean[] mask = fm.apply(SPECIES.length());
5502 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5503
5504 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5505 for (int i = 0; i < a.length; i += SPECIES.length()) {
5506 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5507 av.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i);
5508 }
5509 }
5510
5511 assertArraysEquals(r, a, mask, ByteMaxVectorTests::REVERSE);
5512 }
5513
5514 static byte REVERSE_BYTES(byte a) {
5515 return (byte)(a);
5516 }
5517
5518 @Test(dataProvider = "byteUnaryOpProvider")
5519 static void REVERSE_BYTESByteMaxVectorTests(IntFunction<byte[]> fa) {
5520 byte[] a = fa.apply(SPECIES.length());
5521 byte[] r = fr.apply(SPECIES.length());
5522
5523 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5524 for (int i = 0; i < a.length; i += SPECIES.length()) {
5525 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5526 av.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i);
5527 }
5528 }
5529
5530 assertArraysEquals(r, a, ByteMaxVectorTests::REVERSE_BYTES);
5531 }
5532
5533 @Test(dataProvider = "byteUnaryOpMaskProvider")
5534 static void REVERSE_BYTESMaskedByteMaxVectorTests(IntFunction<byte[]> fa,
5535 IntFunction<boolean[]> fm) {
5536 byte[] a = fa.apply(SPECIES.length());
5537 byte[] r = fr.apply(SPECIES.length());
5538 boolean[] mask = fm.apply(SPECIES.length());
5539 VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5540
5541 for (int ic = 0; ic < INVOC_COUNT; ic++) {
5542 for (int i = 0; i < a.length; i += SPECIES.length()) {
5543 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5544 av.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i);
5545 }
5546 }
5547
5548 assertArraysEquals(r, a, mask, ByteMaxVectorTests::REVERSE_BYTES);
5549 }
5550
5551 @Test(dataProvider = "byteCompareOpProvider")
5552 static void ltByteMaxVectorTestsBroadcastSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5553 byte[] a = fa.apply(SPECIES.length());
5554 byte[] b = fb.apply(SPECIES.length());
5555
5556 for (int i = 0; i < a.length; i += SPECIES.length()) {
5557 ByteVector av = ByteVector.fromArray(SPECIES, a, i);
5558 VectorMask<Byte> mv = av.lt(b[i]);
5559
5560 // Check results as part of computation.
5561 for (int j = 0; j < SPECIES.length(); j++) {
5562 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5563 }
5564 }
5565 }
5566
5567 @Test(dataProvider = "byteCompareOpProvider")
5568 static void eqByteMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<byte[]> fa, IntFunction<byte[]> fb) {
5569 byte[] a = fa.apply(SPECIES.length());
5943 }
5944 }
5945 return i - idx;
5946 }
5947
5948 @Test(dataProvider = "maskProvider")
5949 static void maskFirstTrueByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5950 boolean[] a = fa.apply(SPECIES.length());
5951 int[] r = new int[a.length];
5952
5953 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5954 for (int i = 0; i < a.length; i += SPECIES.length()) {
5955 var vmask = SPECIES.loadMask(a, i);
5956 r[i] = vmask.firstTrue();
5957 }
5958 }
5959
5960 assertMaskReductionArraysEquals(r, a, ByteMaxVectorTests::maskFirstTrue);
5961 }
5962
5963 @Test(dataProvider = "maskProvider")
5964 static void maskCompressByteMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5965 int trueCount = 0;
5966 boolean[] a = fa.apply(SPECIES.length());
5967
5968 for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5969 for (int i = 0; i < a.length; i += SPECIES.length()) {
5970 var vmask = SPECIES.loadMask(a, i);
5971 trueCount = vmask.trueCount();
5972 var rmask = vmask.compress();
5973 for (int j = 0; j < SPECIES.length(); j++) {
5974 Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
5975 }
5976 }
5977 }
5978 }
5979
5980
5981 @DataProvider
5982 public static Object[][] offsetProvider() {
5983 return new Object[][]{
5984 {0},
5985 {-1},
5986 {+1},
5987 {+2},
5988 {-2},
5989 };
5990 }
5991
5992 @Test(dataProvider = "offsetProvider")
5993 static void indexInRangeByteMaxVectorTestsSmokeTest(int offset) {
5994 int limit = SPECIES.length() * BUFFER_REPS;
5995 for (int i = 0; i < limit; i += SPECIES.length()) {
5996 var actualMask = SPECIES.indexInRange(i + offset, limit);
5997 var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5998 assert(actualMask.equals(expectedMask));
5999 for (int j = 0; j < SPECIES.length(); j++) {
6000 int index = i + j + offset;
6001 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
6002 }
6003 }
6004 }
6005
6006 @Test(dataProvider = "offsetProvider")
6007 static void indexInRangeLongByteMaxVectorTestsSmokeTest(int offset) {
6008 long limit = SPECIES.length() * BUFFER_REPS;
6009 for (long i = 0; i < limit; i += SPECIES.length()) {
6010 var actualMask = SPECIES.indexInRange(i + offset, limit);
6011 var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
6012 assert(actualMask.equals(expectedMask));
6013 for (int j = 0; j < SPECIES.length(); j++) {
6014 long index = i + j + offset;
6015 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
6016 }
6017 }
6018 }
6019
6020 @DataProvider
6021 public static Object[][] lengthProvider() {
6022 return new Object[][]{
6023 {0},
6024 {1},
6025 {32},
6026 {37},
6027 {1024},
6028 {1024+1},
6029 {1024+5},
6030 };
6031 }
6032
6033 @Test(dataProvider = "lengthProvider")
6034 static void loopBoundByteMaxVectorTestsSmokeTest(int length) {
6035 int actualLoopBound = SPECIES.loopBound(length);
6036 int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6037 Assert.assertEquals(actualLoopBound, expectedLoopBound);
6038 }
6039
6040 @Test(dataProvider = "lengthProvider")
6041 static void loopBoundLongByteMaxVectorTestsSmokeTest(int _length) {
6042 long length = _length;
6043 long actualLoopBound = SPECIES.loopBound(length);
6044 long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6045 Assert.assertEquals(actualLoopBound, expectedLoopBound);
6046 }
6047
6048 @Test
6049 static void ElementSizeByteMaxVectorTestsSmokeTest() {
6050 ByteVector av = ByteVector.zero(SPECIES);
6051 int elsize = av.elementSize();
6052 Assert.assertEquals(elsize, Byte.SIZE);
6053 }
6054
6055 @Test
6056 static void VectorShapeByteMaxVectorTestsSmokeTest() {
6057 ByteVector av = ByteVector.zero(SPECIES);
6058 VectorShape vsh = av.shape();
6059 assert(vsh.equals(VectorShape.S_Max_BIT));
6060 }
6061
6062 @Test
6063 static void ShapeWithLanesByteMaxVectorTestsSmokeTest() {
6064 ByteVector av = ByteVector.zero(SPECIES);
6065 VectorShape vsh = av.shape();
6066 VectorSpecies species = vsh.withLanes(byte.class);
6067 assert(species.equals(SPECIES));
6090 ByteVector av = ByteVector.zero(SPECIES);
6091 VectorSpecies species = av.species().withLanes(byte.class);
6092 assert(species.equals(SPECIES));
6093 }
6094
6095 @Test
6096 static void WithShapeByteMaxVectorTestsSmokeTest() {
6097 ByteVector av = ByteVector.zero(SPECIES);
6098 VectorShape vsh = av.shape();
6099 VectorSpecies species = av.species().withShape(vsh);
6100 assert(species.equals(SPECIES));
6101 }
6102
6103 @Test
6104 static void MaskAllTrueByteMaxVectorTestsSmokeTest() {
6105 for (int ic = 0; ic < INVOC_COUNT; ic++) {
6106 Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
6107 }
6108 }
6109 }
|