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