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