< prev index next >

test/jdk/jdk/incubator/vector/Short256VectorTests.java

Print this page

 244             } else {
 245                 Assert.assertEquals(r[i], a[i], "at index #" + i);
 246             }
 247         }
 248     }
 249 
 250     static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) {
 251         int i = 0, j = 0;
 252         try {
 253             for (; i < a.length; i += vector_len) {
 254                 for (j = 0; j < vector_len; j++) {
 255                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 256                 }
 257             }
 258         } catch (AssertionError e) {
 259             int idx = i + j;
 260             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 261         }
 262     }
 263 

















































 264     static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) {
 265         int i = 0, j = 0;
 266         try {
 267             for (; i < a.length; i += vector_len) {
 268                 for (j = 0; j < vector_len; j++) {
 269                     Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 270                 }
 271             }
 272         } catch (AssertionError e) {
 273             int idx = i + j;
 274             Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
 275         }
 276     }
 277 
 278     static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) {
 279         int i = 0, j = 0;
 280         try {
 281             for (; i < a.length; i += vector_len) {
 282                 for (j = 0; j < vector_len; j++) {
 283                     if (mask[j % SPECIES.length()])

 867         try {
 868             for (; i < r.length; i++) {
 869                 Assert.assertEquals(r[i], (long)(a[i+offs]));
 870             }
 871         } catch (AssertionError e) {
 872             Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 873         }
 874     }
 875 
 876     static void assertArraysEquals(double[] r, short[] a, int offs) {
 877         int i = 0;
 878         try {
 879             for (; i < r.length; i++) {
 880                 Assert.assertEquals(r[i], (double)(a[i+offs]));
 881             }
 882         } catch (AssertionError e) {
 883             Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 884         }
 885     }
 886 
 887 
 888     static short bits(short e) {
 889         return  e;
 890     }
 891 
 892     static final List<IntFunction<short[]>> SHORT_GENERATORS = List.of(
 893             withToString("short[-i * 5]", (int s) -> {
 894                 return fill(s * BUFFER_REPS,
 895                             i -> (short)(-i * 5));
 896             }),
 897             withToString("short[i * 5]", (int s) -> {
 898                 return fill(s * BUFFER_REPS,
 899                             i -> (short)(i * 5));
 900             }),
 901             withToString("short[i + 1]", (int s) -> {
 902                 return fill(s * BUFFER_REPS,
 903                             i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1)));
 904             }),
 905             withToString("short[cornerCaseValue(i)]", (int s) -> {
 906                 return fill(s * BUFFER_REPS,
 907                             i -> cornerCaseValue(i));

 962                 })).
 963                 toArray(Object[][]::new);
 964     }
 965 
 966     @DataProvider
 967     public Object[][] shortUnaryOpProvider() {
 968         return SHORT_GENERATORS.stream().
 969                 map(f -> new Object[]{f}).
 970                 toArray(Object[][]::new);
 971     }
 972 
 973     @DataProvider
 974     public Object[][] shortUnaryOpMaskProvider() {
 975         return BOOLEAN_MASK_GENERATORS.stream().
 976                 flatMap(fm -> SHORT_GENERATORS.stream().map(fa -> {
 977                     return new Object[] {fa, fm};
 978                 })).
 979                 toArray(Object[][]::new);
 980     }
 981 
 982 
 983 
 984     @DataProvider
 985     public Object[][] maskProvider() {
 986         return BOOLEAN_MASK_GENERATORS.stream().
 987                 map(f -> new Object[]{f}).
 988                 toArray(Object[][]::new);
 989     }
 990 
 991     @DataProvider
 992     public Object[][] maskCompareOpProvider() {
 993         return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
 994                 toArray(Object[][]::new);
 995     }
 996 
 997     @DataProvider
 998     public Object[][] shuffleProvider() {
 999         return INT_SHUFFLE_GENERATORS.stream().
1000                 map(f -> new Object[]{f}).
1001                 toArray(Object[][]::new);
1002     }
1003 

1039 
1040     @DataProvider
1041     public Object[][] shortUnaryOpSelectFromProvider() {
1042         return SHORT_SHUFFLE_GENERATORS.stream().
1043                 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1044                     return new Object[] {fa, fs};
1045                 })).
1046                 toArray(Object[][]::new);
1047     }
1048 
1049     @DataProvider
1050     public Object[][] shortUnaryOpSelectFromMaskProvider() {
1051         return BOOLEAN_MASK_GENERATORS.stream().
1052                 flatMap(fm -> SHORT_SHUFFLE_GENERATORS.stream().
1053                     flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1054                         return new Object[] {fa, fs, fm};
1055                 }))).
1056                 toArray(Object[][]::new);
1057     }
1058 
1059 
1060     static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of(
1061             withToString("short[i]", (int s) -> {
1062                 return fill(s * BUFFER_REPS,
1063                             i -> (short)i);
1064             }),
1065             withToString("short[i - length / 2]", (int s) -> {
1066                 return fill(s * BUFFER_REPS,
1067                             i -> (short)(i - (s * BUFFER_REPS / 2)));
1068             }),
1069             withToString("short[i + 1]", (int s) -> {
1070                 return fill(s * BUFFER_REPS,
1071                             i -> (short)(i + 1));
1072             }),
1073             withToString("short[i - 2]", (int s) -> {
1074                 return fill(s * BUFFER_REPS,
1075                             i -> (short)(i - 2));
1076             }),
1077             withToString("short[zigZag(i)]", (int s) -> {
1078                 return fill(s * BUFFER_REPS,
1079                             i -> i%3 == 0 ? (short)i : (i%3 == 1 ? (short)(i + 1) : (short)(i - 2)));

1180             }
1181         }
1182     }
1183 
1184     static void replaceZero(short[] a, boolean[] mask, short v) {
1185         for (int i = 0; i < a.length; i++) {
1186             if (mask[i % mask.length] && a[i] == 0) {
1187                 a[i] = v;
1188             }
1189         }
1190     }
1191 
1192     static short ROL_scalar(short a, short b) {
1193         return (short)(((((short)a) & 0xFFFF) << (b & 15)) | ((((short)a) & 0xFFFF) >>> (16 - (b & 15))));
1194     }
1195 
1196     static short ROR_scalar(short a, short b) {
1197         return (short)(((((short)a) & 0xFFFF) >>> (b & 15)) | ((((short)a) & 0xFFFF) << (16 - (b & 15))));
1198     }
1199 
















1200     static boolean eq(short a, short b) {
1201         return a == b;
1202     }
1203 
1204     static boolean neq(short a, short b) {
1205         return a != b;
1206     }
1207 
1208     static boolean lt(short a, short b) {
1209         return a < b;
1210     }
1211 
1212     static boolean le(short a, short b) {
1213         return a <= b;
1214     }
1215 
1216     static boolean gt(short a, short b) {
1217         return a > b;
1218     }
1219 

1329     @Test
1330     // Test div by 0.
1331     static void bitwiseDivByZeroSmokeTest() {
1332         try {
1333             ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1334             ShortVector b = (ShortVector) SPECIES.broadcast(0);
1335             a.div(b);
1336             Assert.fail();
1337         } catch (ArithmeticException e) {
1338         }
1339 
1340         try {
1341             ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1342             ShortVector b = (ShortVector) SPECIES.broadcast(0);
1343             VectorMask<Short> m = a.lt((short) 1);
1344             a.div(b, m);
1345             Assert.fail();
1346         } catch (ArithmeticException e) {
1347         }
1348     }

1349     static short ADD(short a, short b) {
1350         return (short)(a + b);
1351     }
1352 
1353     @Test(dataProvider = "shortBinaryOpProvider")
1354     static void ADDShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1355         short[] a = fa.apply(SPECIES.length());
1356         short[] b = fb.apply(SPECIES.length());
1357         short[] r = fr.apply(SPECIES.length());
1358 
1359         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1360             for (int i = 0; i < a.length; i += SPECIES.length()) {
1361                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1362                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1363                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1364             }
1365         }
1366 
1367         assertArraysEquals(r, a, b, Short256VectorTests::ADD);
1368     }

1369     static short add(short a, short b) {
1370         return (short)(a + b);
1371     }
1372 
1373     @Test(dataProvider = "shortBinaryOpProvider")
1374     static void addShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1375         short[] a = fa.apply(SPECIES.length());
1376         short[] b = fb.apply(SPECIES.length());
1377         short[] r = fr.apply(SPECIES.length());
1378 
1379         for (int i = 0; i < a.length; i += SPECIES.length()) {
1380             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1381             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1382             av.add(bv).intoArray(r, i);
1383         }
1384 
1385         assertArraysEquals(r, a, b, Short256VectorTests::add);
1386     }
1387 
1388     @Test(dataProvider = "shortBinaryOpMaskProvider")

1405         assertArraysEquals(r, a, b, mask, Short256VectorTests::ADD);
1406     }
1407 
1408     @Test(dataProvider = "shortBinaryOpMaskProvider")
1409     static void addShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1410                                           IntFunction<boolean[]> fm) {
1411         short[] a = fa.apply(SPECIES.length());
1412         short[] b = fb.apply(SPECIES.length());
1413         short[] r = fr.apply(SPECIES.length());
1414         boolean[] mask = fm.apply(SPECIES.length());
1415         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1416 
1417         for (int i = 0; i < a.length; i += SPECIES.length()) {
1418             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1419             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1420             av.add(bv, vmask).intoArray(r, i);
1421         }
1422 
1423         assertArraysEquals(r, a, b, mask, Short256VectorTests::add);
1424     }

1425     static short SUB(short a, short b) {
1426         return (short)(a - b);
1427     }
1428 
1429     @Test(dataProvider = "shortBinaryOpProvider")
1430     static void SUBShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1431         short[] a = fa.apply(SPECIES.length());
1432         short[] b = fb.apply(SPECIES.length());
1433         short[] r = fr.apply(SPECIES.length());
1434 
1435         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1436             for (int i = 0; i < a.length; i += SPECIES.length()) {
1437                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1438                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1439                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1440             }
1441         }
1442 
1443         assertArraysEquals(r, a, b, Short256VectorTests::SUB);
1444     }

1445     static short sub(short a, short b) {
1446         return (short)(a - b);
1447     }
1448 
1449     @Test(dataProvider = "shortBinaryOpProvider")
1450     static void subShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1451         short[] a = fa.apply(SPECIES.length());
1452         short[] b = fb.apply(SPECIES.length());
1453         short[] r = fr.apply(SPECIES.length());
1454 
1455         for (int i = 0; i < a.length; i += SPECIES.length()) {
1456             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1457             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1458             av.sub(bv).intoArray(r, i);
1459         }
1460 
1461         assertArraysEquals(r, a, b, Short256VectorTests::sub);
1462     }
1463 
1464     @Test(dataProvider = "shortBinaryOpMaskProvider")

1481         assertArraysEquals(r, a, b, mask, Short256VectorTests::SUB);
1482     }
1483 
1484     @Test(dataProvider = "shortBinaryOpMaskProvider")
1485     static void subShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1486                                           IntFunction<boolean[]> fm) {
1487         short[] a = fa.apply(SPECIES.length());
1488         short[] b = fb.apply(SPECIES.length());
1489         short[] r = fr.apply(SPECIES.length());
1490         boolean[] mask = fm.apply(SPECIES.length());
1491         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1492 
1493         for (int i = 0; i < a.length; i += SPECIES.length()) {
1494             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1495             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1496             av.sub(bv, vmask).intoArray(r, i);
1497         }
1498 
1499         assertArraysEquals(r, a, b, mask, Short256VectorTests::sub);
1500     }

1501     static short MUL(short a, short b) {
1502         return (short)(a * b);
1503     }
1504 
1505     @Test(dataProvider = "shortBinaryOpProvider")
1506     static void MULShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1507         short[] a = fa.apply(SPECIES.length());
1508         short[] b = fb.apply(SPECIES.length());
1509         short[] r = fr.apply(SPECIES.length());
1510 
1511         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1512             for (int i = 0; i < a.length; i += SPECIES.length()) {
1513                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1514                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1515                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1516             }
1517         }
1518 
1519         assertArraysEquals(r, a, b, Short256VectorTests::MUL);
1520     }

1521     static short mul(short a, short b) {
1522         return (short)(a * b);
1523     }
1524 
1525     @Test(dataProvider = "shortBinaryOpProvider")
1526     static void mulShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1527         short[] a = fa.apply(SPECIES.length());
1528         short[] b = fb.apply(SPECIES.length());
1529         short[] r = fr.apply(SPECIES.length());
1530 
1531         for (int i = 0; i < a.length; i += SPECIES.length()) {
1532             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1533             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1534             av.mul(bv).intoArray(r, i);
1535         }
1536 
1537         assertArraysEquals(r, a, b, Short256VectorTests::mul);
1538     }
1539 
1540     @Test(dataProvider = "shortBinaryOpMaskProvider")

1558     }
1559 
1560     @Test(dataProvider = "shortBinaryOpMaskProvider")
1561     static void mulShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1562                                           IntFunction<boolean[]> fm) {
1563         short[] a = fa.apply(SPECIES.length());
1564         short[] b = fb.apply(SPECIES.length());
1565         short[] r = fr.apply(SPECIES.length());
1566         boolean[] mask = fm.apply(SPECIES.length());
1567         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1568 
1569         for (int i = 0; i < a.length; i += SPECIES.length()) {
1570             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1571             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1572             av.mul(bv, vmask).intoArray(r, i);
1573         }
1574 
1575         assertArraysEquals(r, a, b, mask, Short256VectorTests::mul);
1576     }
1577 
1578 
1579 
1580     static short DIV(short a, short b) {
1581         return (short)(a / b);
1582     }
1583 
1584     @Test(dataProvider = "shortBinaryOpProvider")
1585     static void DIVShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1586         short[] a = fa.apply(SPECIES.length());
1587         short[] b = fb.apply(SPECIES.length());
1588         short[] r = fr.apply(SPECIES.length());
1589 
1590         replaceZero(b, (short) 1);
1591 
1592         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1593             for (int i = 0; i < a.length; i += SPECIES.length()) {
1594                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1595                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1596                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1597             }
1598         }
1599 
1600         assertArraysEquals(r, a, b, Short256VectorTests::DIV);
1601     }

1602     static short div(short a, short b) {
1603         return (short)(a / b);
1604     }
1605 
1606     @Test(dataProvider = "shortBinaryOpProvider")
1607     static void divShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1608         short[] a = fa.apply(SPECIES.length());
1609         short[] b = fb.apply(SPECIES.length());
1610         short[] r = fr.apply(SPECIES.length());
1611 
1612         replaceZero(b, (short) 1);
1613 
1614         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1615             for (int i = 0; i < a.length; i += SPECIES.length()) {
1616                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1617                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1618                 av.div(bv).intoArray(r, i);
1619             }
1620         }
1621 
1622         assertArraysEquals(r, a, b, Short256VectorTests::div);
1623     }
1624 
1625 
1626 
1627     @Test(dataProvider = "shortBinaryOpMaskProvider")
1628     static void DIVShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1629                                           IntFunction<boolean[]> fm) {
1630         short[] a = fa.apply(SPECIES.length());
1631         short[] b = fb.apply(SPECIES.length());
1632         short[] r = fr.apply(SPECIES.length());
1633         boolean[] mask = fm.apply(SPECIES.length());
1634         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1635 
1636         replaceZero(b, mask, (short) 1);
1637 
1638         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1639             for (int i = 0; i < a.length; i += SPECIES.length()) {
1640                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1641                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1642                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1643             }
1644         }
1645 
1646         assertArraysEquals(r, a, b, mask, Short256VectorTests::DIV);

1712     static short AND(short a, short b) {
1713         return (short)(a & b);
1714     }
1715 
1716     @Test(dataProvider = "shortBinaryOpProvider")
1717     static void ANDShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1718         short[] a = fa.apply(SPECIES.length());
1719         short[] b = fb.apply(SPECIES.length());
1720         short[] r = fr.apply(SPECIES.length());
1721 
1722         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1723             for (int i = 0; i < a.length; i += SPECIES.length()) {
1724                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1725                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1726                 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1727             }
1728         }
1729 
1730         assertArraysEquals(r, a, b, Short256VectorTests::AND);
1731     }

1732     static short and(short a, short b) {
1733         return (short)(a & b);
1734     }
1735 
1736     @Test(dataProvider = "shortBinaryOpProvider")
1737     static void andShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1738         short[] a = fa.apply(SPECIES.length());
1739         short[] b = fb.apply(SPECIES.length());
1740         short[] r = fr.apply(SPECIES.length());
1741 
1742         for (int i = 0; i < a.length; i += SPECIES.length()) {
1743             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1744             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1745             av.and(bv).intoArray(r, i);
1746         }
1747 
1748         assertArraysEquals(r, a, b, Short256VectorTests::and);
1749     }
1750 
1751 
1752 
1753     @Test(dataProvider = "shortBinaryOpMaskProvider")
1754     static void ANDShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1755                                           IntFunction<boolean[]> fm) {
1756         short[] a = fa.apply(SPECIES.length());
1757         short[] b = fb.apply(SPECIES.length());
1758         short[] r = fr.apply(SPECIES.length());
1759         boolean[] mask = fm.apply(SPECIES.length());
1760         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1761 
1762         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1763             for (int i = 0; i < a.length; i += SPECIES.length()) {
1764                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1765                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1766                 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
1767             }
1768         }
1769 
1770         assertArraysEquals(r, a, b, mask, Short256VectorTests::AND);
1771     }
1772 
1773 
1774     static short AND_NOT(short a, short b) {
1775         return (short)(a & ~b);
1776     }
1777 
1778     @Test(dataProvider = "shortBinaryOpProvider")
1779     static void AND_NOTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1780         short[] a = fa.apply(SPECIES.length());
1781         short[] b = fb.apply(SPECIES.length());
1782         short[] r = fr.apply(SPECIES.length());
1783 
1784         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1785             for (int i = 0; i < a.length; i += SPECIES.length()) {
1786                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1787                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1788                 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
1789             }
1790         }
1791 
1792         assertArraysEquals(r, a, b, Short256VectorTests::AND_NOT);
1793     }
1794 
1795 
1796 
1797     @Test(dataProvider = "shortBinaryOpMaskProvider")
1798     static void AND_NOTShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1799                                           IntFunction<boolean[]> fm) {
1800         short[] a = fa.apply(SPECIES.length());
1801         short[] b = fb.apply(SPECIES.length());
1802         short[] r = fr.apply(SPECIES.length());
1803         boolean[] mask = fm.apply(SPECIES.length());
1804         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1805 
1806         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1807             for (int i = 0; i < a.length; i += SPECIES.length()) {
1808                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1809                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1810                 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
1811             }
1812         }
1813 
1814         assertArraysEquals(r, a, b, mask, Short256VectorTests::AND_NOT);
1815     }
1816 
1817 
1818     static short OR(short a, short b) {
1819         return (short)(a | b);
1820     }
1821 
1822     @Test(dataProvider = "shortBinaryOpProvider")
1823     static void ORShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1824         short[] a = fa.apply(SPECIES.length());
1825         short[] b = fb.apply(SPECIES.length());
1826         short[] r = fr.apply(SPECIES.length());
1827 
1828         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1829             for (int i = 0; i < a.length; i += SPECIES.length()) {
1830                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1831                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1832                 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1833             }
1834         }
1835 
1836         assertArraysEquals(r, a, b, Short256VectorTests::OR);
1837     }

1838     static short or(short a, short b) {
1839         return (short)(a | b);
1840     }
1841 
1842     @Test(dataProvider = "shortBinaryOpProvider")
1843     static void orShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1844         short[] a = fa.apply(SPECIES.length());
1845         short[] b = fb.apply(SPECIES.length());
1846         short[] r = fr.apply(SPECIES.length());
1847 
1848         for (int i = 0; i < a.length; i += SPECIES.length()) {
1849             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1850             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1851             av.or(bv).intoArray(r, i);
1852         }
1853 
1854         assertArraysEquals(r, a, b, Short256VectorTests::or);
1855     }
1856 
1857 
1858 
1859     @Test(dataProvider = "shortBinaryOpMaskProvider")
1860     static void ORShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1861                                           IntFunction<boolean[]> fm) {
1862         short[] a = fa.apply(SPECIES.length());
1863         short[] b = fb.apply(SPECIES.length());
1864         short[] r = fr.apply(SPECIES.length());
1865         boolean[] mask = fm.apply(SPECIES.length());
1866         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1867 
1868         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1869             for (int i = 0; i < a.length; i += SPECIES.length()) {
1870                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1871                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1872                 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1873             }
1874         }
1875 
1876         assertArraysEquals(r, a, b, mask, Short256VectorTests::OR);
1877     }
1878 
1879 
1880     static short XOR(short a, short b) {
1881         return (short)(a ^ b);
1882     }
1883 
1884     @Test(dataProvider = "shortBinaryOpProvider")
1885     static void XORShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1886         short[] a = fa.apply(SPECIES.length());
1887         short[] b = fb.apply(SPECIES.length());
1888         short[] r = fr.apply(SPECIES.length());
1889 
1890         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1891             for (int i = 0; i < a.length; i += SPECIES.length()) {
1892                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1893                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1894                 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
1895             }
1896         }
1897 
1898         assertArraysEquals(r, a, b, Short256VectorTests::XOR);
1899     }
1900 
1901 
1902 
1903     @Test(dataProvider = "shortBinaryOpMaskProvider")
1904     static void XORShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1905                                           IntFunction<boolean[]> fm) {
1906         short[] a = fa.apply(SPECIES.length());
1907         short[] b = fb.apply(SPECIES.length());
1908         short[] r = fr.apply(SPECIES.length());
1909         boolean[] mask = fm.apply(SPECIES.length());
1910         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1911 
1912         for (int ic = 0; ic < INVOC_COUNT; ic++) {
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.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1917             }
1918         }
1919 
1920         assertArraysEquals(r, a, b, mask, Short256VectorTests::XOR);
1921     }
1922 
1923 
1924     @Test(dataProvider = "shortBinaryOpProvider")
1925     static void addShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1926         short[] a = fa.apply(SPECIES.length());
1927         short[] b = fb.apply(SPECIES.length());
1928         short[] r = fr.apply(SPECIES.length());
1929 
1930         for (int i = 0; i < a.length; i += SPECIES.length()) {
1931             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1932             av.add(b[i]).intoArray(r, i);
1933         }
1934 
1935         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::add);
1936     }
1937 
1938     @Test(dataProvider = "shortBinaryOpMaskProvider")
1939     static void addShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
1940                                           IntFunction<boolean[]> fm) {
1941         short[] a = fa.apply(SPECIES.length());
1942         short[] b = fb.apply(SPECIES.length());
1943         short[] r = fr.apply(SPECIES.length());

1997         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::mul);
1998     }
1999 
2000     @Test(dataProvider = "shortBinaryOpMaskProvider")
2001     static void mulShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2002                                           IntFunction<boolean[]> fm) {
2003         short[] a = fa.apply(SPECIES.length());
2004         short[] b = fb.apply(SPECIES.length());
2005         short[] r = fr.apply(SPECIES.length());
2006         boolean[] mask = fm.apply(SPECIES.length());
2007         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2008 
2009         for (int i = 0; i < a.length; i += SPECIES.length()) {
2010             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2011             av.mul(b[i], vmask).intoArray(r, i);
2012         }
2013 
2014         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::mul);
2015     }
2016 
2017 
2018 
2019 
2020     @Test(dataProvider = "shortBinaryOpProvider")
2021     static void divShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2022         short[] a = fa.apply(SPECIES.length());
2023         short[] b = fb.apply(SPECIES.length());
2024         short[] r = fr.apply(SPECIES.length());
2025 
2026         replaceZero(b, (short) 1);
2027 
2028         for (int i = 0; i < a.length; i += SPECIES.length()) {
2029             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2030             av.div(b[i]).intoArray(r, i);
2031         }
2032 
2033         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::div);
2034     }
2035 
2036 
2037 
2038     @Test(dataProvider = "shortBinaryOpMaskProvider")
2039     static void divShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2040                                           IntFunction<boolean[]> fm) {
2041         short[] a = fa.apply(SPECIES.length());
2042         short[] b = fb.apply(SPECIES.length());
2043         short[] r = fr.apply(SPECIES.length());
2044         boolean[] mask = fm.apply(SPECIES.length());
2045         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2046 
2047         replaceZero(b, (short) 1);
2048 
2049         for (int i = 0; i < a.length; i += SPECIES.length()) {
2050             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2051             av.div(b[i], vmask).intoArray(r, i);
2052         }
2053 
2054         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::div);
2055     }
2056 
2057 
2058 
2059     @Test(dataProvider = "shortBinaryOpProvider")
2060     static void ORShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2061         short[] a = fa.apply(SPECIES.length());
2062         short[] b = fb.apply(SPECIES.length());
2063         short[] r = fr.apply(SPECIES.length());
2064 
2065         for (int i = 0; i < a.length; i += SPECIES.length()) {
2066             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2067             av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2068         }
2069 
2070         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::OR);
2071     }
2072 
2073     @Test(dataProvider = "shortBinaryOpProvider")
2074     static void orShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2075         short[] a = fa.apply(SPECIES.length());
2076         short[] b = fb.apply(SPECIES.length());
2077         short[] r = fr.apply(SPECIES.length());
2078 
2079         for (int i = 0; i < a.length; i += SPECIES.length()) {
2080             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2081             av.or(b[i]).intoArray(r, i);
2082         }
2083 
2084         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::or);
2085     }
2086 
2087 
2088 
2089     @Test(dataProvider = "shortBinaryOpMaskProvider")
2090     static void ORShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2091                                           IntFunction<boolean[]> fm) {
2092         short[] a = fa.apply(SPECIES.length());
2093         short[] b = fb.apply(SPECIES.length());
2094         short[] r = fr.apply(SPECIES.length());
2095         boolean[] mask = fm.apply(SPECIES.length());
2096         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2097 
2098         for (int i = 0; i < a.length; i += SPECIES.length()) {
2099             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2100             av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2101         }
2102 
2103         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::OR);
2104     }
2105 
2106 
2107 
2108     @Test(dataProvider = "shortBinaryOpProvider")
2109     static void ANDShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2110         short[] a = fa.apply(SPECIES.length());
2111         short[] b = fb.apply(SPECIES.length());
2112         short[] r = fr.apply(SPECIES.length());
2113 
2114         for (int i = 0; i < a.length; i += SPECIES.length()) {
2115             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2116             av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2117         }
2118 
2119         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::AND);
2120     }
2121 
2122     @Test(dataProvider = "shortBinaryOpProvider")
2123     static void andShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2124         short[] a = fa.apply(SPECIES.length());
2125         short[] b = fb.apply(SPECIES.length());
2126         short[] r = fr.apply(SPECIES.length());
2127 
2128         for (int i = 0; i < a.length; i += SPECIES.length()) {
2129             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2130             av.and(b[i]).intoArray(r, i);
2131         }
2132 
2133         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::and);
2134     }
2135 
2136 
2137 
2138     @Test(dataProvider = "shortBinaryOpMaskProvider")
2139     static void ANDShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2140                                           IntFunction<boolean[]> fm) {
2141         short[] a = fa.apply(SPECIES.length());
2142         short[] b = fb.apply(SPECIES.length());
2143         short[] r = fr.apply(SPECIES.length());
2144         boolean[] mask = fm.apply(SPECIES.length());
2145         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2146 
2147         for (int i = 0; i < a.length; i += SPECIES.length()) {
2148             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2149             av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2150         }
2151 
2152         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::AND);
2153     }
2154 
2155 
2156 
2157     @Test(dataProvider = "shortBinaryOpProvider")
2158     static void ORShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2159         short[] a = fa.apply(SPECIES.length());
2160         short[] b = fb.apply(SPECIES.length());
2161         short[] r = fr.apply(SPECIES.length());
2162 
2163         for (int i = 0; i < a.length; i += SPECIES.length()) {
2164             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2165             av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2166         }
2167 
2168         assertBroadcastLongArraysEquals(r, a, b, Short256VectorTests::OR);
2169     }
2170 
2171 
2172 
2173     @Test(dataProvider = "shortBinaryOpMaskProvider")
2174     static void ORShort256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2175                                           IntFunction<boolean[]> fm) {
2176         short[] a = fa.apply(SPECIES.length());
2177         short[] b = fb.apply(SPECIES.length());
2178         short[] r = fr.apply(SPECIES.length());
2179         boolean[] mask = fm.apply(SPECIES.length());
2180         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2181 
2182         for (int i = 0; i < a.length; i += SPECIES.length()) {
2183             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2184             av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2185         }
2186 
2187         assertBroadcastLongArraysEquals(r, a, b, mask, Short256VectorTests::OR);
2188     }
2189 
2190 
2191     @Test(dataProvider = "shortBinaryOpProvider")
2192     static void ADDShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2193         short[] a = fa.apply(SPECIES.length());
2194         short[] b = fb.apply(SPECIES.length());
2195         short[] r = fr.apply(SPECIES.length());
2196 
2197         for (int i = 0; i < a.length; i += SPECIES.length()) {
2198             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2199             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2200         }
2201 
2202         assertBroadcastLongArraysEquals(r, a, b, Short256VectorTests::ADD);
2203     }
2204 
2205     @Test(dataProvider = "shortBinaryOpMaskProvider")
2206     static void ADDShort256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2207                                           IntFunction<boolean[]> fm) {
2208         short[] a = fa.apply(SPECIES.length());
2209         short[] b = fb.apply(SPECIES.length());
2210         short[] r = fr.apply(SPECIES.length());
2211         boolean[] mask = fm.apply(SPECIES.length());
2212         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2213 
2214         for (int i = 0; i < a.length; i += SPECIES.length()) {
2215             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2216             av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
2217         }
2218 
2219         assertBroadcastLongArraysEquals(r, a, b, mask, Short256VectorTests::ADD);
2220     }
2221 
2222 
2223 
2224 
2225 
2226     static short LSHL(short a, short b) {
2227         return (short)((a << (b & 0xF)));
2228     }
2229 
2230     @Test(dataProvider = "shortBinaryOpProvider")
2231     static void LSHLShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2232         short[] a = fa.apply(SPECIES.length());
2233         short[] b = fb.apply(SPECIES.length());
2234         short[] r = fr.apply(SPECIES.length());
2235 
2236         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2237             for (int i = 0; i < a.length; i += SPECIES.length()) {
2238                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2239                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2240                 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2241             }
2242         }
2243 
2244         assertArraysEquals(r, a, b, Short256VectorTests::LSHL);
2245     }
2246 
2247 
2248 
2249     @Test(dataProvider = "shortBinaryOpMaskProvider")
2250     static void LSHLShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2251                                           IntFunction<boolean[]> fm) {
2252         short[] a = fa.apply(SPECIES.length());
2253         short[] b = fb.apply(SPECIES.length());
2254         short[] r = fr.apply(SPECIES.length());
2255         boolean[] mask = fm.apply(SPECIES.length());
2256         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2257 
2258         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2259             for (int i = 0; i < a.length; i += SPECIES.length()) {
2260                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2261                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2262                 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2263             }
2264         }
2265 
2266         assertArraysEquals(r, a, b, mask, Short256VectorTests::LSHL);
2267     }
2268 
2269 
2270 
2271 
2272 
2273 
2274     static short ASHR(short a, short b) {
2275         return (short)((a >> (b & 0xF)));
2276     }
2277 
2278     @Test(dataProvider = "shortBinaryOpProvider")
2279     static void ASHRShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2280         short[] a = fa.apply(SPECIES.length());
2281         short[] b = fb.apply(SPECIES.length());
2282         short[] r = fr.apply(SPECIES.length());
2283 
2284         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2285             for (int i = 0; i < a.length; i += SPECIES.length()) {
2286                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2287                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2288                 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2289             }
2290         }
2291 
2292         assertArraysEquals(r, a, b, Short256VectorTests::ASHR);
2293     }
2294 
2295 
2296 
2297     @Test(dataProvider = "shortBinaryOpMaskProvider")
2298     static void ASHRShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2299                                           IntFunction<boolean[]> fm) {
2300         short[] a = fa.apply(SPECIES.length());
2301         short[] b = fb.apply(SPECIES.length());
2302         short[] r = fr.apply(SPECIES.length());
2303         boolean[] mask = fm.apply(SPECIES.length());
2304         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2305 
2306         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2307             for (int i = 0; i < a.length; i += SPECIES.length()) {
2308                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2309                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2310                 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2311             }
2312         }
2313 
2314         assertArraysEquals(r, a, b, mask, Short256VectorTests::ASHR);
2315     }
2316 
2317 
2318 
2319 
2320 
2321 
2322     static short LSHR(short a, short b) {
2323         return (short)(((a & 0xFFFF) >>> (b & 0xF)));
2324     }
2325 
2326     @Test(dataProvider = "shortBinaryOpProvider")
2327     static void LSHRShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2328         short[] a = fa.apply(SPECIES.length());
2329         short[] b = fb.apply(SPECIES.length());
2330         short[] r = fr.apply(SPECIES.length());
2331 
2332         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2333             for (int i = 0; i < a.length; i += SPECIES.length()) {
2334                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2335                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2336                 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2337             }
2338         }
2339 
2340         assertArraysEquals(r, a, b, Short256VectorTests::LSHR);
2341     }
2342 
2343 
2344 
2345     @Test(dataProvider = "shortBinaryOpMaskProvider")
2346     static void LSHRShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2347                                           IntFunction<boolean[]> fm) {
2348         short[] a = fa.apply(SPECIES.length());
2349         short[] b = fb.apply(SPECIES.length());
2350         short[] r = fr.apply(SPECIES.length());
2351         boolean[] mask = fm.apply(SPECIES.length());
2352         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2353 
2354         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2355             for (int i = 0; i < a.length; i += SPECIES.length()) {
2356                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2357                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2358                 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2359             }
2360         }
2361 
2362         assertArraysEquals(r, a, b, mask, Short256VectorTests::LSHR);
2363     }
2364 
2365 
2366 
2367 
2368 
2369 
2370     static short LSHL_unary(short a, short b) {
2371         return (short)((a << (b & 15)));
2372     }
2373 
2374     @Test(dataProvider = "shortBinaryOpProvider")
2375     static void LSHLShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2376         short[] a = fa.apply(SPECIES.length());
2377         short[] b = fb.apply(SPECIES.length());
2378         short[] r = fr.apply(SPECIES.length());
2379 
2380         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2381             for (int i = 0; i < a.length; i += SPECIES.length()) {
2382                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2383                 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2384             }
2385         }
2386 
2387         assertShiftArraysEquals(r, a, b, Short256VectorTests::LSHL_unary);
2388     }
2389 
2390 
2391 
2392     @Test(dataProvider = "shortBinaryOpMaskProvider")
2393     static void LSHLShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2394                                           IntFunction<boolean[]> fm) {
2395         short[] a = fa.apply(SPECIES.length());
2396         short[] b = fb.apply(SPECIES.length());
2397         short[] r = fr.apply(SPECIES.length());
2398         boolean[] mask = fm.apply(SPECIES.length());
2399         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2400 
2401         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2402             for (int i = 0; i < a.length; i += SPECIES.length()) {
2403                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2404                 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2405             }
2406         }
2407 
2408         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::LSHL_unary);
2409     }
2410 
2411 
2412 
2413 
2414 
2415 
2416     static short LSHR_unary(short a, short b) {
2417         return (short)(((a & 0xFFFF) >>> (b & 15)));
2418     }
2419 
2420     @Test(dataProvider = "shortBinaryOpProvider")
2421     static void LSHRShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2422         short[] a = fa.apply(SPECIES.length());
2423         short[] b = fb.apply(SPECIES.length());
2424         short[] r = fr.apply(SPECIES.length());
2425 
2426         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2427             for (int i = 0; i < a.length; i += SPECIES.length()) {
2428                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2429                 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2430             }
2431         }
2432 
2433         assertShiftArraysEquals(r, a, b, Short256VectorTests::LSHR_unary);
2434     }
2435 
2436 
2437 
2438     @Test(dataProvider = "shortBinaryOpMaskProvider")
2439     static void LSHRShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2440                                           IntFunction<boolean[]> fm) {
2441         short[] a = fa.apply(SPECIES.length());
2442         short[] b = fb.apply(SPECIES.length());
2443         short[] r = fr.apply(SPECIES.length());
2444         boolean[] mask = fm.apply(SPECIES.length());
2445         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2446 
2447         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2448             for (int i = 0; i < a.length; i += SPECIES.length()) {
2449                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2450                 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2451             }
2452         }
2453 
2454         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::LSHR_unary);
2455     }
2456 
2457 
2458 
2459 
2460 
2461 
2462     static short ASHR_unary(short a, short b) {
2463         return (short)((a >> (b & 15)));
2464     }
2465 
2466     @Test(dataProvider = "shortBinaryOpProvider")
2467     static void ASHRShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2468         short[] a = fa.apply(SPECIES.length());
2469         short[] b = fb.apply(SPECIES.length());
2470         short[] r = fr.apply(SPECIES.length());
2471 
2472         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2473             for (int i = 0; i < a.length; i += SPECIES.length()) {
2474                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2475                 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2476             }
2477         }
2478 
2479         assertShiftArraysEquals(r, a, b, Short256VectorTests::ASHR_unary);
2480     }
2481 
2482 
2483 
2484     @Test(dataProvider = "shortBinaryOpMaskProvider")
2485     static void ASHRShort256VectorTestsScalarShiftMasked(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, Short256VectorTests::ASHR_unary);
2501     }
2502 
2503 
2504     static short ROR(short a, short b) {
2505         return (short)(ROR_scalar(a,b));
2506     }
2507 
2508     @Test(dataProvider = "shortBinaryOpProvider")
2509     static void RORShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2510         short[] a = fa.apply(SPECIES.length());
2511         short[] b = fb.apply(SPECIES.length());
2512         short[] r = fr.apply(SPECIES.length());
2513 
2514         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2515             for (int i = 0; i < a.length; i += SPECIES.length()) {
2516                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2517                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2518                 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2519             }
2520         }
2521 
2522         assertArraysEquals(r, a, b, Short256VectorTests::ROR);
2523     }
2524 
2525 
2526 
2527     @Test(dataProvider = "shortBinaryOpMaskProvider")
2528     static void RORShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2529                                           IntFunction<boolean[]> fm) {
2530         short[] a = fa.apply(SPECIES.length());
2531         short[] b = fb.apply(SPECIES.length());
2532         short[] r = fr.apply(SPECIES.length());
2533         boolean[] mask = fm.apply(SPECIES.length());
2534         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2535 
2536         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2537             for (int i = 0; i < a.length; i += SPECIES.length()) {
2538                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2539                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2540                 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2541             }
2542         }
2543 
2544         assertArraysEquals(r, a, b, mask, Short256VectorTests::ROR);
2545     }
2546 
2547 
2548     static short ROL(short a, short b) {
2549         return (short)(ROL_scalar(a,b));
2550     }
2551 
2552     @Test(dataProvider = "shortBinaryOpProvider")
2553     static void ROLShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2554         short[] a = fa.apply(SPECIES.length());
2555         short[] b = fb.apply(SPECIES.length());
2556         short[] r = fr.apply(SPECIES.length());
2557 
2558         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2559             for (int i = 0; i < a.length; i += SPECIES.length()) {
2560                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2561                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2562                 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2563             }
2564         }
2565 
2566         assertArraysEquals(r, a, b, Short256VectorTests::ROL);
2567     }
2568 
2569 
2570 
2571     @Test(dataProvider = "shortBinaryOpMaskProvider")
2572     static void ROLShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2573                                           IntFunction<boolean[]> fm) {
2574         short[] a = fa.apply(SPECIES.length());
2575         short[] b = fb.apply(SPECIES.length());
2576         short[] r = fr.apply(SPECIES.length());
2577         boolean[] mask = fm.apply(SPECIES.length());
2578         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2579 
2580         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2581             for (int i = 0; i < a.length; i += SPECIES.length()) {
2582                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2583                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2584                 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2585             }
2586         }
2587 
2588         assertArraysEquals(r, a, b, mask, Short256VectorTests::ROL);
2589     }
2590 
2591 
2592     static short ROR_unary(short a, short b) {
2593         return (short)(ROR_scalar(a, b));
2594     }
2595 
2596     @Test(dataProvider = "shortBinaryOpProvider")
2597     static void RORShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2598         short[] a = fa.apply(SPECIES.length());
2599         short[] b = fb.apply(SPECIES.length());
2600         short[] r = fr.apply(SPECIES.length());
2601 
2602         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2603             for (int i = 0; i < a.length; i += SPECIES.length()) {
2604                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2605                 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2606             }
2607         }
2608 
2609         assertShiftArraysEquals(r, a, b, Short256VectorTests::ROR_unary);
2610     }
2611 
2612 
2613 
2614     @Test(dataProvider = "shortBinaryOpMaskProvider")
2615     static void RORShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2616                                           IntFunction<boolean[]> fm) {
2617         short[] a = fa.apply(SPECIES.length());
2618         short[] b = fb.apply(SPECIES.length());
2619         short[] r = fr.apply(SPECIES.length());
2620         boolean[] mask = fm.apply(SPECIES.length());
2621         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2622 
2623         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2624             for (int i = 0; i < a.length; i += SPECIES.length()) {
2625                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2626                 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2627             }
2628         }
2629 
2630         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ROR_unary);
2631     }
2632 
2633 
2634     static short ROL_unary(short a, short b) {
2635         return (short)(ROL_scalar(a, b));
2636     }
2637 
2638     @Test(dataProvider = "shortBinaryOpProvider")
2639     static void ROLShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2640         short[] a = fa.apply(SPECIES.length());
2641         short[] b = fb.apply(SPECIES.length());
2642         short[] r = fr.apply(SPECIES.length());
2643 
2644         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2645             for (int i = 0; i < a.length; i += SPECIES.length()) {
2646                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2647                 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2648             }
2649         }
2650 
2651         assertShiftArraysEquals(r, a, b, Short256VectorTests::ROL_unary);
2652     }
2653 
2654 
2655 
2656     @Test(dataProvider = "shortBinaryOpMaskProvider")
2657     static void ROLShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2658                                           IntFunction<boolean[]> fm) {
2659         short[] a = fa.apply(SPECIES.length());
2660         short[] b = fb.apply(SPECIES.length());
2661         short[] r = fr.apply(SPECIES.length());
2662         boolean[] mask = fm.apply(SPECIES.length());
2663         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2664 
2665         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2666             for (int i = 0; i < a.length; i += SPECIES.length()) {
2667                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2668                 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2669             }
2670         }
2671 
2672         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ROL_unary);
2673     }
2674 
2675 
2676 
2677 
2678 
2679 
2680     static short LSHR_binary_const(short a) {
2681         return (short)(((a & 0xFFFF) >>> CONST_SHIFT));
2682     }
2683 
2684     @Test(dataProvider = "shortUnaryOpProvider")
2685     static void LSHRShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2686         short[] a = fa.apply(SPECIES.length());
2687         short[] r = fr.apply(SPECIES.length());
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).intoArray(r, i);
2693             }
2694         }
2695 
2696         assertShiftConstEquals(r, a, Short256VectorTests::LSHR_binary_const);
2697     }
2698 
2699 
2700 
2701     @Test(dataProvider = "shortUnaryOpMaskProvider")
2702     static void LSHRShort256VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2703                                           IntFunction<boolean[]> fm) {
2704         short[] a = fa.apply(SPECIES.length());
2705         short[] r = fr.apply(SPECIES.length());
2706         boolean[] mask = fm.apply(SPECIES.length());
2707         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2708 
2709         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2710             for (int i = 0; i < a.length; i += SPECIES.length()) {
2711                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2712                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
2713             }
2714         }
2715 
2716         assertShiftConstEquals(r, a, mask, Short256VectorTests::LSHR_binary_const);
2717     }
2718 
2719 
2720 
2721     static short LSHL_binary_const(short a) {
2722         return (short)((a << CONST_SHIFT));
2723     }
2724 
2725     @Test(dataProvider = "shortUnaryOpProvider")
2726     static void LSHLShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2727         short[] a = fa.apply(SPECIES.length());
2728         short[] r = fr.apply(SPECIES.length());
2729 
2730         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2731             for (int i = 0; i < a.length; i += SPECIES.length()) {
2732                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2733                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
2734             }
2735         }
2736 
2737         assertShiftConstEquals(r, a, Short256VectorTests::LSHL_binary_const);
2738     }
2739 
2740 
2741 
2742     @Test(dataProvider = "shortUnaryOpMaskProvider")
2743     static void LSHLShort256VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2744                                           IntFunction<boolean[]> fm) {
2745         short[] a = fa.apply(SPECIES.length());
2746         short[] r = fr.apply(SPECIES.length());
2747         boolean[] mask = fm.apply(SPECIES.length());
2748         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2749 
2750         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2751             for (int i = 0; i < a.length; i += SPECIES.length()) {
2752                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2753                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
2754             }
2755         }
2756 
2757         assertShiftConstEquals(r, a, mask, Short256VectorTests::LSHL_binary_const);
2758     }
2759 
2760 
2761 
2762     static short ASHR_binary_const(short a) {
2763         return (short)((a >> CONST_SHIFT));
2764     }
2765 
2766     @Test(dataProvider = "shortUnaryOpProvider")
2767     static void ASHRShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2768         short[] a = fa.apply(SPECIES.length());
2769         short[] r = fr.apply(SPECIES.length());
2770 
2771         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2772             for (int i = 0; i < a.length; i += SPECIES.length()) {
2773                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2774                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
2775             }
2776         }
2777 
2778         assertShiftConstEquals(r, a, Short256VectorTests::ASHR_binary_const);
2779     }
2780 
2781 
2782 
2783     @Test(dataProvider = "shortUnaryOpMaskProvider")
2784     static void ASHRShort256VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2785                                           IntFunction<boolean[]> fm) {
2786         short[] a = fa.apply(SPECIES.length());
2787         short[] r = fr.apply(SPECIES.length());
2788         boolean[] mask = fm.apply(SPECIES.length());
2789         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2790 
2791         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2792             for (int i = 0; i < a.length; i += SPECIES.length()) {
2793                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2794                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
2795             }
2796         }
2797 
2798         assertShiftConstEquals(r, a, mask, Short256VectorTests::ASHR_binary_const);
2799     }
2800 
2801 
2802 
2803     static short ROR_binary_const(short a) {
2804         return (short)(ROR_scalar(a, CONST_SHIFT));
2805     }
2806 
2807     @Test(dataProvider = "shortUnaryOpProvider")
2808     static void RORShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2809         short[] a = fa.apply(SPECIES.length());
2810         short[] r = fr.apply(SPECIES.length());
2811 
2812         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2813             for (int i = 0; i < a.length; i += SPECIES.length()) {
2814                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2815                 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
2816             }
2817         }
2818 
2819         assertShiftConstEquals(r, a, Short256VectorTests::ROR_binary_const);
2820     }
2821 
2822 
2823 
2824     @Test(dataProvider = "shortUnaryOpMaskProvider")
2825     static void RORShort256VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2826                                           IntFunction<boolean[]> fm) {
2827         short[] a = fa.apply(SPECIES.length());
2828         short[] r = fr.apply(SPECIES.length());
2829         boolean[] mask = fm.apply(SPECIES.length());
2830         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2831 
2832         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2833             for (int i = 0; i < a.length; i += SPECIES.length()) {
2834                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2835                 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
2836             }
2837         }
2838 
2839         assertShiftConstEquals(r, a, mask, Short256VectorTests::ROR_binary_const);
2840     }
2841 
2842 
2843 
2844     static short ROL_binary_const(short a) {
2845         return (short)(ROL_scalar(a, CONST_SHIFT));
2846     }
2847 
2848     @Test(dataProvider = "shortUnaryOpProvider")
2849     static void ROLShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2850         short[] a = fa.apply(SPECIES.length());
2851         short[] r = fr.apply(SPECIES.length());
2852 
2853         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2854             for (int i = 0; i < a.length; i += SPECIES.length()) {
2855                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2856                 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
2857             }
2858         }
2859 
2860         assertShiftConstEquals(r, a, Short256VectorTests::ROL_binary_const);
2861     }
2862 
2863 
2864 
2865     @Test(dataProvider = "shortUnaryOpMaskProvider")
2866     static void ROLShort256VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2867                                           IntFunction<boolean[]> fm) {
2868         short[] a = fa.apply(SPECIES.length());
2869         short[] r = fr.apply(SPECIES.length());
2870         boolean[] mask = fm.apply(SPECIES.length());
2871         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2872 
2873         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2874             for (int i = 0; i < a.length; i += SPECIES.length()) {
2875                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2876                 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
2877             }
2878         }
2879 
2880         assertShiftConstEquals(r, a, mask, Short256VectorTests::ROL_binary_const);
2881     }
2882 
2883 
2884     static short MIN(short a, short b) {
2885         return (short)(Math.min(a, b));
2886     }
2887 
2888     @Test(dataProvider = "shortBinaryOpProvider")
2889     static void MINShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2890         short[] a = fa.apply(SPECIES.length());
2891         short[] b = fb.apply(SPECIES.length());
2892         short[] r = fr.apply(SPECIES.length());
2893 
2894         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2895             for (int i = 0; i < a.length; i += SPECIES.length()) {
2896                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2897                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2898                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2899             }
2900         }
2901 
2902         assertArraysEquals(r, a, b, Short256VectorTests::MIN);
2903     }

2904     static short min(short a, short b) {
2905         return (short)(Math.min(a, b));
2906     }
2907 
2908     @Test(dataProvider = "shortBinaryOpProvider")
2909     static void minShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2910         short[] a = fa.apply(SPECIES.length());
2911         short[] b = fb.apply(SPECIES.length());
2912         short[] r = fr.apply(SPECIES.length());
2913 
2914         for (int i = 0; i < a.length; i += SPECIES.length()) {
2915             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2916             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2917             av.min(bv).intoArray(r, i);
2918         }
2919 
2920         assertArraysEquals(r, a, b, Short256VectorTests::min);
2921     }

2922     static short MAX(short a, short b) {
2923         return (short)(Math.max(a, b));
2924     }
2925 
2926     @Test(dataProvider = "shortBinaryOpProvider")
2927     static void MAXShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2928         short[] a = fa.apply(SPECIES.length());
2929         short[] b = fb.apply(SPECIES.length());
2930         short[] r = fr.apply(SPECIES.length());
2931 
2932         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2933             for (int i = 0; i < a.length; i += SPECIES.length()) {
2934                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2935                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2936                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2937             }
2938         }
2939 
2940         assertArraysEquals(r, a, b, Short256VectorTests::MAX);
2941     }

2942     static short max(short a, short b) {
2943         return (short)(Math.max(a, b));
2944     }
2945 
2946     @Test(dataProvider = "shortBinaryOpProvider")
2947     static void maxShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2948         short[] a = fa.apply(SPECIES.length());
2949         short[] b = fb.apply(SPECIES.length());
2950         short[] r = fr.apply(SPECIES.length());
2951 
2952         for (int i = 0; i < a.length; i += SPECIES.length()) {
2953             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2954             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2955             av.max(bv).intoArray(r, i);
2956         }
2957 
2958         assertArraysEquals(r, a, b, Short256VectorTests::max);
2959     }
2960 
2961     @Test(dataProvider = "shortBinaryOpProvider")

3015     }
3016 
3017     static short ANDReduce(short[] a, int idx) {
3018         short res = -1;
3019         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3020             res &= a[i];
3021         }
3022 
3023         return res;
3024     }
3025 
3026     static short ANDReduceAll(short[] a) {
3027         short res = -1;
3028         for (int i = 0; i < a.length; i += SPECIES.length()) {
3029             res &= ANDReduce(a, i);
3030         }
3031 
3032         return res;
3033     }
3034 
3035 
3036     @Test(dataProvider = "shortUnaryOpProvider")
3037     static void ANDReduceShort256VectorTests(IntFunction<short[]> fa) {
3038         short[] a = fa.apply(SPECIES.length());
3039         short[] r = fr.apply(SPECIES.length());
3040         short ra = -1;
3041 
3042         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3043             for (int i = 0; i < a.length; i += SPECIES.length()) {
3044                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3045                 r[i] = av.reduceLanes(VectorOperators.AND);
3046             }
3047         }
3048 
3049         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3050             ra = -1;
3051             for (int i = 0; i < a.length; i += SPECIES.length()) {
3052                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3053                 ra &= av.reduceLanes(VectorOperators.AND);
3054             }
3055         }
3056 
3057         assertReductionArraysEquals(r, ra, a,
3058                 Short256VectorTests::ANDReduce, Short256VectorTests::ANDReduceAll);
3059     }
3060 
3061 
3062     static short ANDReduceMasked(short[] a, int idx, boolean[] mask) {
3063         short res = -1;
3064         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3065             if (mask[i % SPECIES.length()])
3066                 res &= a[i];
3067         }
3068 
3069         return res;
3070     }
3071 
3072     static short ANDReduceAllMasked(short[] a, boolean[] mask) {
3073         short res = -1;
3074         for (int i = 0; i < a.length; i += SPECIES.length()) {
3075             res &= ANDReduceMasked(a, i, mask);
3076         }
3077 
3078         return res;
3079     }
3080 
3081 
3082     @Test(dataProvider = "shortUnaryOpMaskProvider")
3083     static void ANDReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3084         short[] a = fa.apply(SPECIES.length());
3085         short[] r = fr.apply(SPECIES.length());
3086         boolean[] mask = fm.apply(SPECIES.length());
3087         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3088         short ra = -1;
3089 
3090         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3091             for (int i = 0; i < a.length; i += SPECIES.length()) {
3092                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3093                 r[i] = av.reduceLanes(VectorOperators.AND, vmask);
3094             }
3095         }
3096 
3097         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3098             ra = -1;
3099             for (int i = 0; i < a.length; i += SPECIES.length()) {
3100                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3101                 ra &= av.reduceLanes(VectorOperators.AND, vmask);
3102             }
3103         }
3104 
3105         assertReductionArraysEqualsMasked(r, ra, a, mask,
3106                 Short256VectorTests::ANDReduceMasked, Short256VectorTests::ANDReduceAllMasked);
3107     }
3108 
3109 
3110     static short ORReduce(short[] a, int idx) {
3111         short res = 0;
3112         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3113             res |= a[i];
3114         }
3115 
3116         return res;
3117     }
3118 
3119     static short ORReduceAll(short[] a) {
3120         short res = 0;
3121         for (int i = 0; i < a.length; i += SPECIES.length()) {
3122             res |= ORReduce(a, i);
3123         }
3124 
3125         return res;
3126     }
3127 
3128 
3129     @Test(dataProvider = "shortUnaryOpProvider")
3130     static void ORReduceShort256VectorTests(IntFunction<short[]> fa) {
3131         short[] a = fa.apply(SPECIES.length());
3132         short[] r = fr.apply(SPECIES.length());
3133         short ra = 0;
3134 
3135         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3136             for (int i = 0; i < a.length; i += SPECIES.length()) {
3137                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3138                 r[i] = av.reduceLanes(VectorOperators.OR);
3139             }
3140         }
3141 
3142         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3143             ra = 0;
3144             for (int i = 0; i < a.length; i += SPECIES.length()) {
3145                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3146                 ra |= av.reduceLanes(VectorOperators.OR);
3147             }
3148         }
3149 
3150         assertReductionArraysEquals(r, ra, a,
3151                 Short256VectorTests::ORReduce, Short256VectorTests::ORReduceAll);
3152     }
3153 
3154 
3155     static short ORReduceMasked(short[] a, int idx, boolean[] mask) {
3156         short res = 0;
3157         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3158             if (mask[i % SPECIES.length()])
3159                 res |= a[i];
3160         }
3161 
3162         return res;
3163     }
3164 
3165     static short ORReduceAllMasked(short[] a, boolean[] mask) {
3166         short res = 0;
3167         for (int i = 0; i < a.length; i += SPECIES.length()) {
3168             res |= ORReduceMasked(a, i, mask);
3169         }
3170 
3171         return res;
3172     }
3173 
3174 
3175     @Test(dataProvider = "shortUnaryOpMaskProvider")
3176     static void ORReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3177         short[] a = fa.apply(SPECIES.length());
3178         short[] r = fr.apply(SPECIES.length());
3179         boolean[] mask = fm.apply(SPECIES.length());
3180         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3181         short ra = 0;
3182 
3183         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3184             for (int i = 0; i < a.length; i += SPECIES.length()) {
3185                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3186                 r[i] = av.reduceLanes(VectorOperators.OR, vmask);
3187             }
3188         }
3189 
3190         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3191             ra = 0;
3192             for (int i = 0; i < a.length; i += SPECIES.length()) {
3193                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3194                 ra |= av.reduceLanes(VectorOperators.OR, vmask);
3195             }
3196         }
3197 
3198         assertReductionArraysEqualsMasked(r, ra, a, mask,
3199                 Short256VectorTests::ORReduceMasked, Short256VectorTests::ORReduceAllMasked);
3200     }
3201 
3202 
3203     static short XORReduce(short[] a, int idx) {
3204         short res = 0;
3205         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3206             res ^= a[i];
3207         }
3208 
3209         return res;
3210     }
3211 
3212     static short XORReduceAll(short[] a) {
3213         short res = 0;
3214         for (int i = 0; i < a.length; i += SPECIES.length()) {
3215             res ^= XORReduce(a, i);
3216         }
3217 
3218         return res;
3219     }
3220 
3221 
3222     @Test(dataProvider = "shortUnaryOpProvider")
3223     static void XORReduceShort256VectorTests(IntFunction<short[]> fa) {
3224         short[] a = fa.apply(SPECIES.length());
3225         short[] r = fr.apply(SPECIES.length());
3226         short ra = 0;
3227 
3228         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3229             for (int i = 0; i < a.length; i += SPECIES.length()) {
3230                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3231                 r[i] = av.reduceLanes(VectorOperators.XOR);
3232             }
3233         }
3234 
3235         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3236             ra = 0;
3237             for (int i = 0; i < a.length; i += SPECIES.length()) {
3238                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3239                 ra ^= av.reduceLanes(VectorOperators.XOR);
3240             }
3241         }
3242 
3243         assertReductionArraysEquals(r, ra, a,
3244                 Short256VectorTests::XORReduce, Short256VectorTests::XORReduceAll);
3245     }
3246 
3247 
3248     static short XORReduceMasked(short[] a, int idx, boolean[] mask) {
3249         short res = 0;
3250         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3251             if (mask[i % SPECIES.length()])
3252                 res ^= a[i];
3253         }
3254 
3255         return res;
3256     }
3257 
3258     static short XORReduceAllMasked(short[] a, boolean[] mask) {
3259         short res = 0;
3260         for (int i = 0; i < a.length; i += SPECIES.length()) {
3261             res ^= XORReduceMasked(a, i, mask);
3262         }
3263 
3264         return res;
3265     }
3266 
3267 
3268     @Test(dataProvider = "shortUnaryOpMaskProvider")
3269     static void XORReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3270         short[] a = fa.apply(SPECIES.length());
3271         short[] r = fr.apply(SPECIES.length());
3272         boolean[] mask = fm.apply(SPECIES.length());
3273         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3274         short ra = 0;
3275 
3276         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3277             for (int i = 0; i < a.length; i += SPECIES.length()) {
3278                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3279                 r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
3280             }
3281         }
3282 
3283         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3284             ra = 0;
3285             for (int i = 0; i < a.length; i += SPECIES.length()) {
3286                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3287                 ra ^= av.reduceLanes(VectorOperators.XOR, vmask);

3292                 Short256VectorTests::XORReduceMasked, Short256VectorTests::XORReduceAllMasked);
3293     }
3294 
3295     static short ADDReduce(short[] a, int idx) {
3296         short res = 0;
3297         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3298             res += a[i];
3299         }
3300 
3301         return res;
3302     }
3303 
3304     static short ADDReduceAll(short[] a) {
3305         short res = 0;
3306         for (int i = 0; i < a.length; i += SPECIES.length()) {
3307             res += ADDReduce(a, i);
3308         }
3309 
3310         return res;
3311     }

3312     @Test(dataProvider = "shortUnaryOpProvider")
3313     static void ADDReduceShort256VectorTests(IntFunction<short[]> fa) {
3314         short[] a = fa.apply(SPECIES.length());
3315         short[] r = fr.apply(SPECIES.length());
3316         short ra = 0;
3317 
3318         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3319             for (int i = 0; i < a.length; i += SPECIES.length()) {
3320                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3321                 r[i] = av.reduceLanes(VectorOperators.ADD);
3322             }
3323         }
3324 
3325         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3326             ra = 0;
3327             for (int i = 0; i < a.length; i += SPECIES.length()) {
3328                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3329                 ra += av.reduceLanes(VectorOperators.ADD);
3330             }
3331         }
3332 
3333         assertReductionArraysEquals(r, ra, a,
3334                 Short256VectorTests::ADDReduce, Short256VectorTests::ADDReduceAll);
3335     }

3336     static short ADDReduceMasked(short[] a, int idx, boolean[] mask) {
3337         short res = 0;
3338         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3339             if (mask[i % SPECIES.length()])
3340                 res += a[i];
3341         }
3342 
3343         return res;
3344     }
3345 
3346     static short ADDReduceAllMasked(short[] a, boolean[] mask) {
3347         short res = 0;
3348         for (int i = 0; i < a.length; i += SPECIES.length()) {
3349             res += ADDReduceMasked(a, i, mask);
3350         }
3351 
3352         return res;
3353     }

3354     @Test(dataProvider = "shortUnaryOpMaskProvider")
3355     static void ADDReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3356         short[] a = fa.apply(SPECIES.length());
3357         short[] r = fr.apply(SPECIES.length());
3358         boolean[] mask = fm.apply(SPECIES.length());
3359         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3360         short ra = 0;
3361 
3362         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3363             for (int i = 0; i < a.length; i += SPECIES.length()) {
3364                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3365                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3366             }
3367         }
3368 
3369         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3370             ra = 0;
3371             for (int i = 0; i < a.length; i += SPECIES.length()) {
3372                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3373                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3374             }
3375         }
3376 
3377         assertReductionArraysEqualsMasked(r, ra, a, mask,
3378                 Short256VectorTests::ADDReduceMasked, Short256VectorTests::ADDReduceAllMasked);
3379     }

3380     static short MULReduce(short[] a, int idx) {
3381         short res = 1;
3382         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3383             res *= a[i];
3384         }
3385 
3386         return res;
3387     }
3388 
3389     static short MULReduceAll(short[] a) {
3390         short res = 1;
3391         for (int i = 0; i < a.length; i += SPECIES.length()) {
3392             res *= MULReduce(a, i);
3393         }
3394 
3395         return res;
3396     }

3397     @Test(dataProvider = "shortUnaryOpProvider")
3398     static void MULReduceShort256VectorTests(IntFunction<short[]> fa) {
3399         short[] a = fa.apply(SPECIES.length());
3400         short[] r = fr.apply(SPECIES.length());
3401         short ra = 1;
3402 
3403         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3404             for (int i = 0; i < a.length; i += SPECIES.length()) {
3405                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3406                 r[i] = av.reduceLanes(VectorOperators.MUL);
3407             }
3408         }
3409 
3410         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3411             ra = 1;
3412             for (int i = 0; i < a.length; i += SPECIES.length()) {
3413                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3414                 ra *= av.reduceLanes(VectorOperators.MUL);
3415             }
3416         }
3417 
3418         assertReductionArraysEquals(r, ra, a,
3419                 Short256VectorTests::MULReduce, Short256VectorTests::MULReduceAll);
3420     }

3421     static short MULReduceMasked(short[] a, int idx, boolean[] mask) {
3422         short res = 1;
3423         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3424             if (mask[i % SPECIES.length()])
3425                 res *= a[i];
3426         }
3427 
3428         return res;
3429     }
3430 
3431     static short MULReduceAllMasked(short[] a, boolean[] mask) {
3432         short res = 1;
3433         for (int i = 0; i < a.length; i += SPECIES.length()) {
3434             res *= MULReduceMasked(a, i, mask);
3435         }
3436 
3437         return res;
3438     }

3439     @Test(dataProvider = "shortUnaryOpMaskProvider")
3440     static void MULReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3441         short[] a = fa.apply(SPECIES.length());
3442         short[] r = fr.apply(SPECIES.length());
3443         boolean[] mask = fm.apply(SPECIES.length());
3444         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3445         short ra = 1;
3446 
3447         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3448             for (int i = 0; i < a.length; i += SPECIES.length()) {
3449                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3450                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3451             }
3452         }
3453 
3454         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3455             ra = 1;
3456             for (int i = 0; i < a.length; i += SPECIES.length()) {
3457                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3458                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
3459             }
3460         }
3461 
3462         assertReductionArraysEqualsMasked(r, ra, a, mask,
3463                 Short256VectorTests::MULReduceMasked, Short256VectorTests::MULReduceAllMasked);
3464     }

3465     static short MINReduce(short[] a, int idx) {
3466         short res = Short.MAX_VALUE;
3467         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3468             res = (short) Math.min(res, a[i]);
3469         }
3470 
3471         return res;
3472     }
3473 
3474     static short MINReduceAll(short[] a) {
3475         short res = Short.MAX_VALUE;
3476         for (int i = 0; i < a.length; i += SPECIES.length()) {
3477             res = (short) Math.min(res, MINReduce(a, i));
3478         }
3479 
3480         return res;
3481     }

3482     @Test(dataProvider = "shortUnaryOpProvider")
3483     static void MINReduceShort256VectorTests(IntFunction<short[]> fa) {
3484         short[] a = fa.apply(SPECIES.length());
3485         short[] r = fr.apply(SPECIES.length());
3486         short ra = Short.MAX_VALUE;
3487 
3488         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3489             for (int i = 0; i < a.length; i += SPECIES.length()) {
3490                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3491                 r[i] = av.reduceLanes(VectorOperators.MIN);
3492             }
3493         }
3494 
3495         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3496             ra = Short.MAX_VALUE;
3497             for (int i = 0; i < a.length; i += SPECIES.length()) {
3498                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3499                 ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
3500             }
3501         }
3502 
3503         assertReductionArraysEquals(r, ra, a,
3504                 Short256VectorTests::MINReduce, Short256VectorTests::MINReduceAll);
3505     }

3506     static short MINReduceMasked(short[] a, int idx, boolean[] mask) {
3507         short res = Short.MAX_VALUE;
3508         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3509             if (mask[i % SPECIES.length()])
3510                 res = (short) Math.min(res, a[i]);
3511         }
3512 
3513         return res;
3514     }
3515 
3516     static short MINReduceAllMasked(short[] a, boolean[] mask) {
3517         short res = Short.MAX_VALUE;
3518         for (int i = 0; i < a.length; i += SPECIES.length()) {
3519             res = (short) Math.min(res, MINReduceMasked(a, i, mask));
3520         }
3521 
3522         return res;
3523     }

3524     @Test(dataProvider = "shortUnaryOpMaskProvider")
3525     static void MINReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3526         short[] a = fa.apply(SPECIES.length());
3527         short[] r = fr.apply(SPECIES.length());
3528         boolean[] mask = fm.apply(SPECIES.length());
3529         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3530         short ra = Short.MAX_VALUE;
3531 
3532         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3533             for (int i = 0; i < a.length; i += SPECIES.length()) {
3534                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3535                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
3536             }
3537         }
3538 
3539         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3540             ra = Short.MAX_VALUE;
3541             for (int i = 0; i < a.length; i += SPECIES.length()) {
3542                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3543                 ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
3544             }
3545         }
3546 
3547         assertReductionArraysEqualsMasked(r, ra, a, mask,
3548                 Short256VectorTests::MINReduceMasked, Short256VectorTests::MINReduceAllMasked);
3549     }

3550     static short MAXReduce(short[] a, int idx) {
3551         short res = Short.MIN_VALUE;
3552         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3553             res = (short) Math.max(res, a[i]);
3554         }
3555 
3556         return res;
3557     }
3558 
3559     static short MAXReduceAll(short[] a) {
3560         short res = Short.MIN_VALUE;
3561         for (int i = 0; i < a.length; i += SPECIES.length()) {
3562             res = (short) Math.max(res, MAXReduce(a, i));
3563         }
3564 
3565         return res;
3566     }

3567     @Test(dataProvider = "shortUnaryOpProvider")
3568     static void MAXReduceShort256VectorTests(IntFunction<short[]> fa) {
3569         short[] a = fa.apply(SPECIES.length());
3570         short[] r = fr.apply(SPECIES.length());
3571         short ra = Short.MIN_VALUE;
3572 
3573         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3574             for (int i = 0; i < a.length; i += SPECIES.length()) {
3575                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3576                 r[i] = av.reduceLanes(VectorOperators.MAX);
3577             }
3578         }
3579 
3580         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3581             ra = Short.MIN_VALUE;
3582             for (int i = 0; i < a.length; i += SPECIES.length()) {
3583                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3584                 ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
3585             }
3586         }
3587 
3588         assertReductionArraysEquals(r, ra, a,
3589                 Short256VectorTests::MAXReduce, Short256VectorTests::MAXReduceAll);
3590     }

3591     static short MAXReduceMasked(short[] a, int idx, boolean[] mask) {
3592         short res = Short.MIN_VALUE;
3593         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3594             if (mask[i % SPECIES.length()])
3595                 res = (short) Math.max(res, a[i]);
3596         }
3597 
3598         return res;
3599     }
3600 
3601     static short MAXReduceAllMasked(short[] a, boolean[] mask) {
3602         short res = Short.MIN_VALUE;
3603         for (int i = 0; i < a.length; i += SPECIES.length()) {
3604             res = (short) Math.max(res, MAXReduceMasked(a, i, mask));
3605         }
3606 
3607         return res;
3608     }

3609     @Test(dataProvider = "shortUnaryOpMaskProvider")
3610     static void MAXReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3611         short[] a = fa.apply(SPECIES.length());
3612         short[] r = fr.apply(SPECIES.length());
3613         boolean[] mask = fm.apply(SPECIES.length());
3614         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3615         short ra = Short.MIN_VALUE;
3616 
3617         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3618             for (int i = 0; i < a.length; i += SPECIES.length()) {
3619                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3620                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
3621             }
3622         }
3623 
3624         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3625             ra = Short.MIN_VALUE;
3626             for (int i = 0; i < a.length; i += SPECIES.length()) {
3627                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3628                 ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
3629             }
3630         }
3631 
3632         assertReductionArraysEqualsMasked(r, ra, a, mask,
3633                 Short256VectorTests::MAXReduceMasked, Short256VectorTests::MAXReduceAllMasked);
3634     }

3635     static short FIRST_NONZEROReduce(short[] a, int idx) {
3636         short res = (short) 0;
3637         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3638             res = firstNonZero(res, a[i]);
3639         }
3640 
3641         return res;
3642     }
3643 
3644     static short FIRST_NONZEROReduceAll(short[] a) {
3645         short res = (short) 0;
3646         for (int i = 0; i < a.length; i += SPECIES.length()) {
3647             res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
3648         }
3649 
3650         return res;
3651     }

3652     @Test(dataProvider = "shortUnaryOpProvider")
3653     static void FIRST_NONZEROReduceShort256VectorTests(IntFunction<short[]> fa) {
3654         short[] a = fa.apply(SPECIES.length());
3655         short[] r = fr.apply(SPECIES.length());
3656         short ra = (short) 0;
3657 
3658         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3659             for (int i = 0; i < a.length; i += SPECIES.length()) {
3660                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3661                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
3662             }
3663         }
3664 
3665         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3666             ra = (short) 0;
3667             for (int i = 0; i < a.length; i += SPECIES.length()) {
3668                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3669                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
3670             }
3671         }
3672 
3673         assertReductionArraysEquals(r, ra, a,
3674                 Short256VectorTests::FIRST_NONZEROReduce, Short256VectorTests::FIRST_NONZEROReduceAll);
3675     }

3676     static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) {
3677         short res = (short) 0;
3678         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3679             if (mask[i % SPECIES.length()])
3680                 res = firstNonZero(res, a[i]);
3681         }
3682 
3683         return res;
3684     }
3685 
3686     static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) {
3687         short res = (short) 0;
3688         for (int i = 0; i < a.length; i += SPECIES.length()) {
3689             res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
3690         }
3691 
3692         return res;
3693     }

3694     @Test(dataProvider = "shortUnaryOpMaskProvider")
3695     static void FIRST_NONZEROReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3696         short[] a = fa.apply(SPECIES.length());
3697         short[] r = fr.apply(SPECIES.length());
3698         boolean[] mask = fm.apply(SPECIES.length());
3699         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3700         short ra = (short) 0;
3701 
3702         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3703             for (int i = 0; i < a.length; i += SPECIES.length()) {
3704                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3705                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
3706             }
3707         }
3708 
3709         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3710             ra = (short) 0;
3711             for (int i = 0; i < a.length; i += SPECIES.length()) {
3712                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3713                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
3714             }
3715         }
3716 
3717         assertReductionArraysEqualsMasked(r, ra, a, mask,
3718                 Short256VectorTests::FIRST_NONZEROReduceMasked, Short256VectorTests::FIRST_NONZEROReduceAllMasked);
3719     }
3720 
3721     static boolean anyTrue(boolean[] a, int idx) {
3722         boolean res = false;
3723         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3724             res |= a[i];
3725         }
3726 
3727         return res;
3728     }
3729 
3730 
3731     @Test(dataProvider = "boolUnaryOpProvider")
3732     static void anyTrueShort256VectorTests(IntFunction<boolean[]> fm) {
3733         boolean[] mask = fm.apply(SPECIES.length());
3734         boolean[] r = fmr.apply(SPECIES.length());
3735 
3736         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3737             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3738                 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);
3739                 r[i] = vmask.anyTrue();
3740             }
3741         }
3742 
3743         assertReductionBoolArraysEquals(r, mask, Short256VectorTests::anyTrue);
3744     }
3745 
3746 
3747     static boolean allTrue(boolean[] a, int idx) {
3748         boolean res = true;
3749         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3750             res &= a[i];
3751         }
3752 
3753         return res;
3754     }
3755 
3756 
3757     @Test(dataProvider = "boolUnaryOpProvider")
3758     static void allTrueShort256VectorTests(IntFunction<boolean[]> fm) {
3759         boolean[] mask = fm.apply(SPECIES.length());
3760         boolean[] r = fmr.apply(SPECIES.length());
3761 
3762         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3763             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3764                 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);
3765                 r[i] = vmask.allTrue();
3766             }
3767         }
3768 
3769         assertReductionBoolArraysEquals(r, mask, Short256VectorTests::allTrue);
3770     }
3771 
3772 
3773     @Test(dataProvider = "shortUnaryOpProvider")
3774     static void withShort256VectorTests(IntFunction<short []> fa) {
3775         short[] a = fa.apply(SPECIES.length());
3776         short[] r = fr.apply(SPECIES.length());
3777 
3778         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3779             for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3780                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3781                 av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i);
3782             }
3783         }
3784 
3785 
3786         for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3787             assertInsertArraysEquals(r, a, (short)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
3788         }
3789     }

3790     static boolean testIS_DEFAULT(short a) {
3791         return bits(a)==0;
3792     }
3793 
3794     @Test(dataProvider = "shortTestOpProvider")
3795     static void IS_DEFAULTShort256VectorTests(IntFunction<short[]> fa) {
3796         short[] a = fa.apply(SPECIES.length());
3797 
3798         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3799             for (int i = 0; i < a.length; i += SPECIES.length()) {
3800                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3801                 VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT);
3802 
3803                 // Check results as part of computation.
3804                 for (int j = 0; j < SPECIES.length(); j++) {
3805                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3806                 }
3807             }
3808         }
3809     }
3810 
3811     @Test(dataProvider = "shortTestOpMaskProvider")
3812     static void IS_DEFAULTMaskedShort256VectorTests(IntFunction<short[]> fa,
3813                                           IntFunction<boolean[]> fm) {
3814         short[] a = fa.apply(SPECIES.length());
3815         boolean[] mask = fm.apply(SPECIES.length());
3816         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3817 
3818         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3819             for (int i = 0; i < a.length; i += SPECIES.length()) {
3820                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3821                 VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3822 
3823                 // Check results as part of computation.
3824                 for (int j = 0; j < SPECIES.length(); j++) {
3825                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3826                 }
3827             }
3828         }
3829     }

3830     static boolean testIS_NEGATIVE(short a) {
3831         return bits(a)<0;
3832     }
3833 
3834     @Test(dataProvider = "shortTestOpProvider")
3835     static void IS_NEGATIVEShort256VectorTests(IntFunction<short[]> fa) {
3836         short[] a = fa.apply(SPECIES.length());
3837 
3838         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3839             for (int i = 0; i < a.length; i += SPECIES.length()) {
3840                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3841                 VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE);
3842 
3843                 // Check results as part of computation.
3844                 for (int j = 0; j < SPECIES.length(); j++) {
3845                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3846                 }
3847             }
3848         }
3849     }

3851     @Test(dataProvider = "shortTestOpMaskProvider")
3852     static void IS_NEGATIVEMaskedShort256VectorTests(IntFunction<short[]> fa,
3853                                           IntFunction<boolean[]> fm) {
3854         short[] a = fa.apply(SPECIES.length());
3855         boolean[] mask = fm.apply(SPECIES.length());
3856         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3857 
3858         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3859             for (int i = 0; i < a.length; i += SPECIES.length()) {
3860                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3861                 VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3862 
3863                 // Check results as part of computation.
3864                 for (int j = 0; j < SPECIES.length(); j++) {
3865                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3866                 }
3867             }
3868         }
3869     }
3870 
3871 
3872 
3873 
3874     @Test(dataProvider = "shortCompareOpProvider")
3875     static void LTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3876         short[] a = fa.apply(SPECIES.length());
3877         short[] b = fb.apply(SPECIES.length());
3878 
3879         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3880             for (int i = 0; i < a.length; i += SPECIES.length()) {
3881                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3882                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3883                 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv);
3884 
3885                 // Check results as part of computation.
3886                 for (int j = 0; j < SPECIES.length(); j++) {
3887                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3888                 }
3889             }
3890         }
3891     }
3892 
3893 
3894     @Test(dataProvider = "shortCompareOpProvider")
3895     static void ltShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3896         short[] a = fa.apply(SPECIES.length());
3897         short[] b = fb.apply(SPECIES.length());
3898 
3899         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3900             for (int i = 0; i < a.length; i += SPECIES.length()) {
3901                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3902                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3903                 VectorMask<Short> mv = av.lt(bv);
3904 
3905                 // Check results as part of computation.
3906                 for (int j = 0; j < SPECIES.length(); j++) {
3907                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3908                 }
3909             }
3910         }
3911     }
3912 
3913     @Test(dataProvider = "shortCompareOpMaskProvider")

3916         short[] a = fa.apply(SPECIES.length());
3917         short[] b = fb.apply(SPECIES.length());
3918         boolean[] mask = fm.apply(SPECIES.length());
3919 
3920         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3921 
3922         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3923             for (int i = 0; i < a.length; i += SPECIES.length()) {
3924                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3925                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3926                 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv, vmask);
3927 
3928                 // Check results as part of computation.
3929                 for (int j = 0; j < SPECIES.length(); j++) {
3930                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3931                 }
3932             }
3933         }
3934     }
3935 
3936 
3937     @Test(dataProvider = "shortCompareOpProvider")
3938     static void GTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3939         short[] a = fa.apply(SPECIES.length());
3940         short[] b = fb.apply(SPECIES.length());
3941 
3942         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3943             for (int i = 0; i < a.length; i += SPECIES.length()) {
3944                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3945                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3946                 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv);
3947 
3948                 // Check results as part of computation.
3949                 for (int j = 0; j < SPECIES.length(); j++) {
3950                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3951                 }
3952             }
3953         }
3954     }
3955 
3956     @Test(dataProvider = "shortCompareOpMaskProvider")

3959         short[] a = fa.apply(SPECIES.length());
3960         short[] b = fb.apply(SPECIES.length());
3961         boolean[] mask = fm.apply(SPECIES.length());
3962 
3963         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3964 
3965         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3966             for (int i = 0; i < a.length; i += SPECIES.length()) {
3967                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3968                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3969                 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv, vmask);
3970 
3971                 // Check results as part of computation.
3972                 for (int j = 0; j < SPECIES.length(); j++) {
3973                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
3974                 }
3975             }
3976         }
3977     }
3978 
3979 
3980     @Test(dataProvider = "shortCompareOpProvider")
3981     static void EQShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3982         short[] a = fa.apply(SPECIES.length());
3983         short[] b = fb.apply(SPECIES.length());
3984 
3985         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3986             for (int i = 0; i < a.length; i += SPECIES.length()) {
3987                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3988                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3989                 VectorMask<Short> mv = av.compare(VectorOperators.EQ, bv);
3990 
3991                 // Check results as part of computation.
3992                 for (int j = 0; j < SPECIES.length(); j++) {
3993                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3994                 }
3995             }
3996         }
3997     }
3998 
3999 
4000     @Test(dataProvider = "shortCompareOpProvider")
4001     static void eqShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4002         short[] a = fa.apply(SPECIES.length());
4003         short[] b = fb.apply(SPECIES.length());
4004 
4005         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4006             for (int i = 0; i < a.length; i += SPECIES.length()) {
4007                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4008                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4009                 VectorMask<Short> mv = av.eq(bv);
4010 
4011                 // Check results as part of computation.
4012                 for (int j = 0; j < SPECIES.length(); j++) {
4013                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4014                 }
4015             }
4016         }
4017     }
4018 
4019     @Test(dataProvider = "shortCompareOpMaskProvider")

4022         short[] a = fa.apply(SPECIES.length());
4023         short[] b = fb.apply(SPECIES.length());
4024         boolean[] mask = fm.apply(SPECIES.length());
4025 
4026         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4027 
4028         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4029             for (int i = 0; i < a.length; i += SPECIES.length()) {
4030                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4031                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4032                 VectorMask<Short> mv = av.compare(VectorOperators.EQ, bv, vmask);
4033 
4034                 // Check results as part of computation.
4035                 for (int j = 0; j < SPECIES.length(); j++) {
4036                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
4037                 }
4038             }
4039         }
4040     }
4041 
4042 
4043     @Test(dataProvider = "shortCompareOpProvider")
4044     static void NEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4045         short[] a = fa.apply(SPECIES.length());
4046         short[] b = fb.apply(SPECIES.length());
4047 
4048         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4049             for (int i = 0; i < a.length; i += SPECIES.length()) {
4050                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4051                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4052                 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv);
4053 
4054                 // Check results as part of computation.
4055                 for (int j = 0; j < SPECIES.length(); j++) {
4056                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
4057                 }
4058             }
4059         }
4060     }
4061 
4062     @Test(dataProvider = "shortCompareOpMaskProvider")

4065         short[] a = fa.apply(SPECIES.length());
4066         short[] b = fb.apply(SPECIES.length());
4067         boolean[] mask = fm.apply(SPECIES.length());
4068 
4069         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4070 
4071         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4072             for (int i = 0; i < a.length; i += SPECIES.length()) {
4073                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4074                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4075                 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv, vmask);
4076 
4077                 // Check results as part of computation.
4078                 for (int j = 0; j < SPECIES.length(); j++) {
4079                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
4080                 }
4081             }
4082         }
4083     }
4084 
4085 
4086     @Test(dataProvider = "shortCompareOpProvider")
4087     static void LEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4088         short[] a = fa.apply(SPECIES.length());
4089         short[] b = fb.apply(SPECIES.length());
4090 
4091         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4092             for (int i = 0; i < a.length; i += SPECIES.length()) {
4093                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4094                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4095                 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv);
4096 
4097                 // Check results as part of computation.
4098                 for (int j = 0; j < SPECIES.length(); j++) {
4099                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
4100                 }
4101             }
4102         }
4103     }
4104 
4105     @Test(dataProvider = "shortCompareOpMaskProvider")

4108         short[] a = fa.apply(SPECIES.length());
4109         short[] b = fb.apply(SPECIES.length());
4110         boolean[] mask = fm.apply(SPECIES.length());
4111 
4112         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4113 
4114         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4115             for (int i = 0; i < a.length; i += SPECIES.length()) {
4116                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4117                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4118                 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv, vmask);
4119 
4120                 // Check results as part of computation.
4121                 for (int j = 0; j < SPECIES.length(); j++) {
4122                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
4123                 }
4124             }
4125         }
4126     }
4127 
4128 
4129     @Test(dataProvider = "shortCompareOpProvider")
4130     static void GEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4131         short[] a = fa.apply(SPECIES.length());
4132         short[] b = fb.apply(SPECIES.length());
4133 
4134         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4135             for (int i = 0; i < a.length; i += SPECIES.length()) {
4136                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4137                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4138                 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv);
4139 
4140                 // Check results as part of computation.
4141                 for (int j = 0; j < SPECIES.length(); j++) {
4142                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
4143                 }
4144             }
4145         }
4146     }
4147 
4148     @Test(dataProvider = "shortCompareOpMaskProvider")

4151         short[] a = fa.apply(SPECIES.length());
4152         short[] b = fb.apply(SPECIES.length());
4153         boolean[] mask = fm.apply(SPECIES.length());
4154 
4155         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4156 
4157         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4158             for (int i = 0; i < a.length; i += SPECIES.length()) {
4159                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4160                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4161                 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv, vmask);
4162 
4163                 // Check results as part of computation.
4164                 for (int j = 0; j < SPECIES.length(); j++) {
4165                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
4166                 }
4167             }
4168         }
4169     }
4170 
4171 
4172 
4173     @Test(dataProvider = "shortCompareOpProvider")
4174     static void UNSIGNED_LTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4175         short[] a = fa.apply(SPECIES.length());
4176         short[] b = fb.apply(SPECIES.length());
4177 
4178         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4179             for (int i = 0; i < a.length; i += SPECIES.length()) {
4180                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4181                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4182                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
4183 
4184                 // Check results as part of computation.
4185                 for (int j = 0; j < SPECIES.length(); j++) {
4186                     Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
4187                 }
4188             }
4189         }
4190     }
4191 
4192 
4193 
4194     @Test(dataProvider = "shortCompareOpMaskProvider")
4195     static void UNSIGNED_LTShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4196                                                 IntFunction<boolean[]> fm) {
4197         short[] a = fa.apply(SPECIES.length());
4198         short[] b = fb.apply(SPECIES.length());
4199         boolean[] mask = fm.apply(SPECIES.length());
4200 
4201         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4202 
4203         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4204             for (int i = 0; i < a.length; i += SPECIES.length()) {
4205                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4206                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4207                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
4208 
4209                 // Check results as part of computation.
4210                 for (int j = 0; j < SPECIES.length(); j++) {
4211                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
4212                 }
4213             }
4214         }
4215     }
4216 
4217 
4218 
4219 
4220     @Test(dataProvider = "shortCompareOpProvider")
4221     static void UNSIGNED_GTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4222         short[] a = fa.apply(SPECIES.length());
4223         short[] b = fb.apply(SPECIES.length());
4224 
4225         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4226             for (int i = 0; i < a.length; i += SPECIES.length()) {
4227                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4228                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4229                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
4230 
4231                 // Check results as part of computation.
4232                 for (int j = 0; j < SPECIES.length(); j++) {
4233                     Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
4234                 }
4235             }
4236         }
4237     }
4238 
4239 
4240 
4241     @Test(dataProvider = "shortCompareOpMaskProvider")
4242     static void UNSIGNED_GTShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4243                                                 IntFunction<boolean[]> fm) {
4244         short[] a = fa.apply(SPECIES.length());
4245         short[] b = fb.apply(SPECIES.length());
4246         boolean[] mask = fm.apply(SPECIES.length());
4247 
4248         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4249 
4250         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4251             for (int i = 0; i < a.length; i += SPECIES.length()) {
4252                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4253                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4254                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
4255 
4256                 // Check results as part of computation.
4257                 for (int j = 0; j < SPECIES.length(); j++) {
4258                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
4259                 }
4260             }
4261         }
4262     }
4263 
4264 
4265 
4266 
4267     @Test(dataProvider = "shortCompareOpProvider")
4268     static void UNSIGNED_LEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4269         short[] a = fa.apply(SPECIES.length());
4270         short[] b = fb.apply(SPECIES.length());
4271 
4272         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4273             for (int i = 0; i < a.length; i += SPECIES.length()) {
4274                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4275                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4276                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
4277 
4278                 // Check results as part of computation.
4279                 for (int j = 0; j < SPECIES.length(); j++) {
4280                     Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
4281                 }
4282             }
4283         }
4284     }
4285 
4286 
4287 
4288     @Test(dataProvider = "shortCompareOpMaskProvider")
4289     static void UNSIGNED_LEShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4290                                                 IntFunction<boolean[]> fm) {
4291         short[] a = fa.apply(SPECIES.length());
4292         short[] b = fb.apply(SPECIES.length());
4293         boolean[] mask = fm.apply(SPECIES.length());
4294 
4295         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4296 
4297         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4298             for (int i = 0; i < a.length; i += SPECIES.length()) {
4299                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4300                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4301                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
4302 
4303                 // Check results as part of computation.
4304                 for (int j = 0; j < SPECIES.length(); j++) {
4305                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
4306                 }
4307             }
4308         }
4309     }
4310 
4311 
4312 
4313 
4314     @Test(dataProvider = "shortCompareOpProvider")
4315     static void UNSIGNED_GEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4316         short[] a = fa.apply(SPECIES.length());
4317         short[] b = fb.apply(SPECIES.length());
4318 
4319         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4320             for (int i = 0; i < a.length; i += SPECIES.length()) {
4321                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4322                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4323                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
4324 
4325                 // Check results as part of computation.
4326                 for (int j = 0; j < SPECIES.length(); j++) {
4327                     Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
4328                 }
4329             }
4330         }
4331     }
4332 
4333 
4334 
4335     @Test(dataProvider = "shortCompareOpMaskProvider")
4336     static void UNSIGNED_GEShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4337                                                 IntFunction<boolean[]> fm) {
4338         short[] a = fa.apply(SPECIES.length());
4339         short[] b = fb.apply(SPECIES.length());
4340         boolean[] mask = fm.apply(SPECIES.length());
4341 
4342         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4343 
4344         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4345             for (int i = 0; i < a.length; i += SPECIES.length()) {
4346                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4347                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4348                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
4349 
4350                 // Check results as part of computation.
4351                 for (int j = 0; j < SPECIES.length(); j++) {
4352                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
4353                 }
4354             }
4355         }
4356     }
4357 
4358 
4359 
4360     @Test(dataProvider = "shortCompareOpProvider")
4361     static void LTShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4362         short[] a = fa.apply(SPECIES.length());
4363         short[] b = fb.apply(SPECIES.length());
4364 
4365         for (int i = 0; i < a.length; i += SPECIES.length()) {
4366             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4367             VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i]);
4368 
4369             // Check results as part of computation.
4370             for (int j = 0; j < SPECIES.length(); j++) {
4371                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4372             }
4373         }
4374     }
4375 
4376 
4377     @Test(dataProvider = "shortCompareOpMaskProvider")
4378     static void LTShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
4379                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4380         short[] a = fa.apply(SPECIES.length());
4381         short[] b = fb.apply(SPECIES.length());
4382         boolean[] mask = fm.apply(SPECIES.length());
4383 
4384         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4385 
4386         for (int i = 0; i < a.length; i += SPECIES.length()) {
4387             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4388             VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i], vmask);
4389 
4390             // Check results as part of computation.
4391             for (int j = 0; j < SPECIES.length(); j++) {
4392                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
4393             }
4394         }
4395     }
4396 
4397     @Test(dataProvider = "shortCompareOpProvider")
4398     static void LTShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4399         short[] a = fa.apply(SPECIES.length());
4400         short[] b = fb.apply(SPECIES.length());
4401 
4402         for (int i = 0; i < a.length; i += SPECIES.length()) {
4403             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4404             VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i]);
4405 
4406             // Check results as part of computation.
4407             for (int j = 0; j < SPECIES.length(); j++) {
4408                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i]));
4409             }
4410         }
4411     }
4412 
4413 
4414     @Test(dataProvider = "shortCompareOpMaskProvider")
4415     static void LTShort256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
4416                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4417         short[] a = fa.apply(SPECIES.length());
4418         short[] b = fb.apply(SPECIES.length());
4419         boolean[] mask = fm.apply(SPECIES.length());
4420 
4421         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4422 
4423         for (int i = 0; i < a.length; i += SPECIES.length()) {
4424             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4425             VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
4426 
4427             // Check results as part of computation.
4428             for (int j = 0; j < SPECIES.length(); j++) {
4429                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (short)((long)b[i])));
4430             }
4431         }
4432     }
4433 
4434     @Test(dataProvider = "shortCompareOpProvider")
4435     static void EQShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4436         short[] a = fa.apply(SPECIES.length());
4437         short[] b = fb.apply(SPECIES.length());
4438 
4439         for (int i = 0; i < a.length; i += SPECIES.length()) {
4440             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4441             VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i]);
4442 
4443             // Check results as part of computation.
4444             for (int j = 0; j < SPECIES.length(); j++) {
4445                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4446             }
4447         }
4448     }
4449 
4450 
4451     @Test(dataProvider = "shortCompareOpMaskProvider")
4452     static void EQShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
4453                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4454         short[] a = fa.apply(SPECIES.length());
4455         short[] b = fb.apply(SPECIES.length());
4456         boolean[] mask = fm.apply(SPECIES.length());
4457 
4458         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4459 
4460         for (int i = 0; i < a.length; i += SPECIES.length()) {
4461             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4462             VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i], vmask);
4463 
4464             // Check results as part of computation.
4465             for (int j = 0; j < SPECIES.length(); j++) {
4466                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
4467             }
4468         }
4469     }
4470 
4471     @Test(dataProvider = "shortCompareOpProvider")
4472     static void EQShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4473         short[] a = fa.apply(SPECIES.length());
4474         short[] b = fb.apply(SPECIES.length());
4475 
4476         for (int i = 0; i < a.length; i += SPECIES.length()) {
4477             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4478             VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i]);
4479 
4480             // Check results as part of computation.
4481             for (int j = 0; j < SPECIES.length(); j++) {
4482                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i]));
4483             }
4484         }
4485     }
4486 
4487 
4488     @Test(dataProvider = "shortCompareOpMaskProvider")
4489     static void EQShort256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
4490                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4491         short[] a = fa.apply(SPECIES.length());
4492         short[] b = fb.apply(SPECIES.length());
4493         boolean[] mask = fm.apply(SPECIES.length());
4494 
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             VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
4500 
4501             // Check results as part of computation.
4502             for (int j = 0; j < SPECIES.length(); j++) {
4503                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (short)((long)b[i])));
4504             }
4505         }
4506     }
4507 

4546         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
4547     }
4548 
4549     @Test(dataProvider = "shortUnaryOpShuffleMaskProvider")
4550     static void RearrangeShort256VectorTestsMaskedSmokeTest(IntFunction<short[]> fa,
4551                                                           BiFunction<Integer,Integer,int[]> fs,
4552                                                           IntFunction<boolean[]> fm) {
4553         short[] a = fa.apply(SPECIES.length());
4554         int[] order = fs.apply(a.length, SPECIES.length());
4555         short[] r = fr.apply(SPECIES.length());
4556         boolean[] mask = fm.apply(SPECIES.length());
4557         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4558 
4559         for (int i = 0; i < a.length; i += SPECIES.length()) {
4560             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4561             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
4562         }
4563 
4564         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
4565     }





































4566     @Test(dataProvider = "shortUnaryOpProvider")
4567     static void getShort256VectorTests(IntFunction<short[]> fa) {
4568         short[] a = fa.apply(SPECIES.length());
4569         short[] r = fr.apply(SPECIES.length());
4570 
4571         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4572             for (int i = 0; i < a.length; i += SPECIES.length()) {
4573                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4574                 int num_lanes = SPECIES.length();
4575                 // Manually unroll because full unroll happens after intrinsification.
4576                 // Unroll is needed because get intrinsic requires for index to be a known constant.
4577                 if (num_lanes == 1) {
4578                     r[i]=av.lane(0);
4579                 } else if (num_lanes == 2) {
4580                     r[i]=av.lane(0);
4581                     r[i+1]=av.lane(1);
4582                 } else if (num_lanes == 4) {
4583                     r[i]=av.lane(0);
4584                     r[i+1]=av.lane(1);
4585                     r[i+2]=av.lane(2);

4716             }
4717         }
4718 
4719         assertArraysEquals(r, a, Short256VectorTests::get);
4720     }
4721 
4722     @Test(dataProvider = "shortUnaryOpProvider")
4723     static void BroadcastShort256VectorTests(IntFunction<short[]> fa) {
4724         short[] a = fa.apply(SPECIES.length());
4725         short[] r = new short[a.length];
4726 
4727         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4728             for (int i = 0; i < a.length; i += SPECIES.length()) {
4729                 ShortVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4730             }
4731         }
4732 
4733         assertBroadcastArraysEquals(r, a);
4734     }
4735 
4736 
4737 
4738 
4739 
4740     @Test(dataProvider = "shortUnaryOpProvider")
4741     static void ZeroShort256VectorTests(IntFunction<short[]> fa) {
4742         short[] a = fa.apply(SPECIES.length());
4743         short[] r = new short[a.length];
4744 
4745         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4746             for (int i = 0; i < a.length; i += SPECIES.length()) {
4747                 ShortVector.zero(SPECIES).intoArray(a, i);
4748             }
4749         }
4750 
4751         Assert.assertEquals(a, r);
4752     }
4753 
4754 
4755 
4756 
4757     static short[] sliceUnary(short[] a, int origin, int idx) {
4758         short[] res = new short[SPECIES.length()];
4759         for (int i = 0; i < SPECIES.length(); i++){
4760             if(i+origin < SPECIES.length())
4761                 res[i] = a[idx+i+origin];
4762             else
4763                 res[i] = (short)0;
4764         }
4765         return res;
4766     }
4767 
4768     @Test(dataProvider = "shortUnaryOpProvider")
4769     static void sliceUnaryShort256VectorTests(IntFunction<short[]> fa) {
4770         short[] a = fa.apply(SPECIES.length());
4771         short[] r = new short[a.length];
4772         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4773         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4774             for (int i = 0; i < a.length; i += SPECIES.length()) {
4775                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4776                 av.slice(origin).intoArray(r, i);
4777             }
4778         }
4779 
4780         assertArraysEquals(r, a, origin, Short256VectorTests::sliceUnary);
4781     }

4782     static short[] sliceBinary(short[] a, short[] b, int origin, int idx) {
4783         short[] res = new short[SPECIES.length()];
4784         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4785             if(i+origin < SPECIES.length())
4786                 res[i] = a[idx+i+origin];
4787             else {
4788                 res[i] = b[idx+j];
4789                 j++;
4790             }
4791         }
4792         return res;
4793     }
4794 
4795     @Test(dataProvider = "shortBinaryOpProvider")
4796     static void sliceBinaryShort256VectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4797         short[] a = fa.apply(SPECIES.length());
4798         short[] b = fb.apply(SPECIES.length());
4799         short[] r = new short[a.length];
4800         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4801         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4802             for (int i = 0; i < a.length; i += SPECIES.length()) {
4803                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4804                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4805                 av.slice(origin, bv).intoArray(r, i);
4806             }
4807         }
4808 
4809         assertArraysEquals(r, a, b, origin, Short256VectorTests::sliceBinary);
4810     }

4811     static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) {
4812         short[] res = new short[SPECIES.length()];
4813         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4814             if(i+origin < SPECIES.length())
4815                 res[i] = mask[i] ? a[idx+i+origin] : (short)0;
4816             else {
4817                 res[i] = mask[i] ? b[idx+j] : (short)0;
4818                 j++;
4819             }
4820         }
4821         return res;
4822     }
4823 
4824     @Test(dataProvider = "shortBinaryOpMaskProvider")
4825     static void sliceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4826     IntFunction<boolean[]> fm) {
4827         short[] a = fa.apply(SPECIES.length());
4828         short[] b = fb.apply(SPECIES.length());
4829         boolean[] mask = fm.apply(SPECIES.length());
4830         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4831 
4832         short[] r = new short[a.length];
4833         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4834         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4835             for (int i = 0; i < a.length; i += SPECIES.length()) {
4836                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4837                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4838                 av.slice(origin, bv, vmask).intoArray(r, i);
4839             }
4840         }
4841 
4842         assertArraysEquals(r, a, b, origin, mask, Short256VectorTests::slice);
4843     }

4844     static short[] unsliceUnary(short[] a, int origin, int idx) {
4845         short[] res = new short[SPECIES.length()];
4846         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4847             if(i < origin)
4848                 res[i] = (short)0;
4849             else {
4850                 res[i] = a[idx+j];
4851                 j++;
4852             }
4853         }
4854         return res;
4855     }
4856 
4857     @Test(dataProvider = "shortUnaryOpProvider")
4858     static void unsliceUnaryShort256VectorTests(IntFunction<short[]> fa) {
4859         short[] a = fa.apply(SPECIES.length());
4860         short[] r = new short[a.length];
4861         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4862         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4863             for (int i = 0; i < a.length; i += SPECIES.length()) {
4864                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4865                 av.unslice(origin).intoArray(r, i);
4866             }
4867         }
4868 
4869         assertArraysEquals(r, a, origin, Short256VectorTests::unsliceUnary);
4870     }

4871     static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) {
4872         short[] res = new short[SPECIES.length()];
4873         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4874             if (part == 0) {
4875                 if (i < origin)
4876                     res[i] = b[idx+i];
4877                 else {
4878                     res[i] = a[idx+j];
4879                     j++;
4880                 }
4881             } else if (part == 1) {
4882                 if (i < origin)
4883                     res[i] = a[idx+SPECIES.length()-origin+i];
4884                 else {
4885                     res[i] = b[idx+origin+j];
4886                     j++;
4887                 }
4888             }
4889         }
4890         return res;
4891     }
4892 
4893     @Test(dataProvider = "shortBinaryOpProvider")
4894     static void unsliceBinaryShort256VectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4895         short[] a = fa.apply(SPECIES.length());
4896         short[] b = fb.apply(SPECIES.length());
4897         short[] r = new short[a.length];
4898         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4899         int part = (new java.util.Random()).nextInt(2);
4900         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4901             for (int i = 0; i < a.length; i += SPECIES.length()) {
4902                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4903                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4904                 av.unslice(origin, bv, part).intoArray(r, i);
4905             }
4906         }
4907 
4908         assertArraysEquals(r, a, b, origin, part, Short256VectorTests::unsliceBinary);
4909     }

4910     static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) {
4911         short[] res = new short[SPECIES.length()];
4912         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4913             if(i+origin < SPECIES.length())
4914                 res[i] = b[idx+i+origin];
4915             else {
4916                 res[i] = b[idx+j];
4917                 j++;
4918             }
4919         }
4920         for (int i = 0; i < SPECIES.length(); i++){
4921             res[i] = mask[i] ? a[idx+i] : res[i];
4922         }
4923         short[] res1 = new short[SPECIES.length()];
4924         if (part == 0) {
4925             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4926                 if (i < origin)
4927                     res1[i] = b[idx+i];
4928                 else {
4929                    res1[i] = res[j];

4947     static void unsliceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4948     IntFunction<boolean[]> fm) {
4949         short[] a = fa.apply(SPECIES.length());
4950         short[] b = fb.apply(SPECIES.length());
4951         boolean[] mask = fm.apply(SPECIES.length());
4952         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4953         short[] r = new short[a.length];
4954         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4955         int part = (new java.util.Random()).nextInt(2);
4956         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4957             for (int i = 0; i < a.length; i += SPECIES.length()) {
4958                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4959                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4960                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
4961             }
4962         }
4963 
4964         assertArraysEquals(r, a, b, origin, part, mask, Short256VectorTests::unslice);
4965     }
4966 
4967 
4968 
4969 
4970 
4971 
4972 
4973 
4974 
4975 
4976 
4977 
4978 
4979 
4980 
4981 
4982 
4983 
4984 
4985 
4986 
4987 
4988 
4989     static short BITWISE_BLEND(short a, short b, short c) {
4990         return (short)((a&~(c))|(b&c));
4991     }

4992     static short bitwiseBlend(short a, short b, short c) {
4993         return (short)((a&~(c))|(b&c));
4994     }
4995 
4996 
4997     @Test(dataProvider = "shortTernaryOpProvider")
4998     static void BITWISE_BLENDShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
4999         short[] a = fa.apply(SPECIES.length());
5000         short[] b = fb.apply(SPECIES.length());
5001         short[] c = fc.apply(SPECIES.length());
5002         short[] r = fr.apply(SPECIES.length());
5003 
5004         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5005             for (int i = 0; i < a.length; i += SPECIES.length()) {
5006                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5007                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5008                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5009                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
5010             }
5011         }
5012 
5013         assertArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
5014     }

5015     @Test(dataProvider = "shortTernaryOpProvider")
5016     static void bitwiseBlendShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5017         short[] a = fa.apply(SPECIES.length());
5018         short[] b = fb.apply(SPECIES.length());
5019         short[] c = fc.apply(SPECIES.length());
5020         short[] r = fr.apply(SPECIES.length());
5021 
5022         for (int i = 0; i < a.length; i += SPECIES.length()) {
5023             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5024             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5025             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5026             av.bitwiseBlend(bv, cv).intoArray(r, i);
5027         }
5028 
5029         assertArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
5030     }
5031 
5032 
5033     @Test(dataProvider = "shortTernaryOpMaskProvider")
5034     static void BITWISE_BLENDShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
5035                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5036         short[] a = fa.apply(SPECIES.length());
5037         short[] b = fb.apply(SPECIES.length());
5038         short[] c = fc.apply(SPECIES.length());
5039         short[] r = fr.apply(SPECIES.length());
5040         boolean[] mask = fm.apply(SPECIES.length());
5041         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5042 
5043         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5044             for (int i = 0; i < a.length; i += SPECIES.length()) {
5045                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5046                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5047                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5048                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
5049             }
5050         }
5051 
5052         assertArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
5053     }
5054 
5055 
5056 
5057 
5058     @Test(dataProvider = "shortTernaryOpProvider")
5059     static void BITWISE_BLENDShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5060         short[] a = fa.apply(SPECIES.length());
5061         short[] b = fb.apply(SPECIES.length());
5062         short[] c = fc.apply(SPECIES.length());
5063         short[] r = fr.apply(SPECIES.length());
5064 
5065         for (int i = 0; i < a.length; i += SPECIES.length()) {
5066             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5067             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5068             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
5069         }
5070         assertBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
5071     }
5072 
5073     @Test(dataProvider = "shortTernaryOpProvider")
5074     static void BITWISE_BLENDShort256VectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5075         short[] a = fa.apply(SPECIES.length());
5076         short[] b = fb.apply(SPECIES.length());
5077         short[] c = fc.apply(SPECIES.length());
5078         short[] r = fr.apply(SPECIES.length());
5079 
5080         for (int i = 0; i < a.length; i += SPECIES.length()) {
5081             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5082             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5083             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
5084         }
5085         assertAltBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
5086     }

5087     @Test(dataProvider = "shortTernaryOpProvider")
5088     static void bitwiseBlendShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5089         short[] a = fa.apply(SPECIES.length());
5090         short[] b = fb.apply(SPECIES.length());
5091         short[] c = fc.apply(SPECIES.length());
5092         short[] r = fr.apply(SPECIES.length());
5093 
5094         for (int i = 0; i < a.length; i += SPECIES.length()) {
5095             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5096             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5097             av.bitwiseBlend(bv, c[i]).intoArray(r, i);
5098         }
5099         assertBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
5100     }
5101 
5102     @Test(dataProvider = "shortTernaryOpProvider")
5103     static void bitwiseBlendShort256VectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5104         short[] a = fa.apply(SPECIES.length());
5105         short[] b = fb.apply(SPECIES.length());
5106         short[] c = fc.apply(SPECIES.length());
5107         short[] r = fr.apply(SPECIES.length());
5108 
5109         for (int i = 0; i < a.length; i += SPECIES.length()) {
5110             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5111             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5112             av.bitwiseBlend(b[i], cv).intoArray(r, i);
5113         }
5114         assertAltBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
5115     }
5116 
5117 
5118     @Test(dataProvider = "shortTernaryOpMaskProvider")
5119     static void BITWISE_BLENDShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5120                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
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         boolean[] mask = fm.apply(SPECIES.length());
5126         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5127 
5128         for (int i = 0; i < a.length; i += SPECIES.length()) {
5129             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5130             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5131             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
5132         }
5133 
5134         assertBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
5135     }
5136 
5137     @Test(dataProvider = "shortTernaryOpMaskProvider")
5138     static void BITWISE_BLENDShort256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5139                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5140         short[] a = fa.apply(SPECIES.length());
5141         short[] b = fb.apply(SPECIES.length());
5142         short[] c = fc.apply(SPECIES.length());
5143         short[] r = fr.apply(SPECIES.length());
5144         boolean[] mask = fm.apply(SPECIES.length());
5145         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5146 
5147         for (int i = 0; i < a.length; i += SPECIES.length()) {
5148             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5149             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5150             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
5151         }
5152 
5153         assertAltBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
5154     }
5155 
5156 
5157 
5158 
5159     @Test(dataProvider = "shortTernaryOpProvider")
5160     static void BITWISE_BLENDShort256VectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5161         short[] a = fa.apply(SPECIES.length());
5162         short[] b = fb.apply(SPECIES.length());
5163         short[] c = fc.apply(SPECIES.length());
5164         short[] r = fr.apply(SPECIES.length());
5165 
5166         for (int i = 0; i < a.length; i += SPECIES.length()) {
5167             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5168             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
5169         }
5170 
5171         assertDoubleBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
5172     }

5173     @Test(dataProvider = "shortTernaryOpProvider")
5174     static void bitwiseBlendShort256VectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5175         short[] a = fa.apply(SPECIES.length());
5176         short[] b = fb.apply(SPECIES.length());
5177         short[] c = fc.apply(SPECIES.length());
5178         short[] r = fr.apply(SPECIES.length());
5179 
5180         for (int i = 0; i < a.length; i += SPECIES.length()) {
5181             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5182             av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
5183         }
5184 
5185         assertDoubleBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
5186     }
5187 
5188 
5189     @Test(dataProvider = "shortTernaryOpMaskProvider")
5190     static void BITWISE_BLENDShort256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5191                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5192         short[] a = fa.apply(SPECIES.length());
5193         short[] b = fb.apply(SPECIES.length());
5194         short[] c = fc.apply(SPECIES.length());
5195         short[] r = fr.apply(SPECIES.length());
5196         boolean[] mask = fm.apply(SPECIES.length());
5197         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5198 
5199         for (int i = 0; i < a.length; i += SPECIES.length()) {
5200             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5201             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
5202         }
5203 
5204         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
5205     }
5206 
5207 
5208     static short NEG(short a) {
5209         return (short)(-((short)a));
5210     }
5211 
5212     static short neg(short a) {
5213         return (short)(-((short)a));
5214     }
5215 
5216     @Test(dataProvider = "shortUnaryOpProvider")
5217     static void NEGShort256VectorTests(IntFunction<short[]> fa) {
5218         short[] a = fa.apply(SPECIES.length());
5219         short[] r = fr.apply(SPECIES.length());
5220 
5221         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5222             for (int i = 0; i < a.length; i += SPECIES.length()) {
5223                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5224                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
5225             }
5226         }
5227 

5300     }
5301 
5302     @Test(dataProvider = "shortUnaryOpMaskProvider")
5303     static void ABSMaskedShort256VectorTests(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.ABS, vmask).intoArray(r, i);
5314             }
5315         }
5316 
5317         assertArraysEquals(r, a, mask, Short256VectorTests::ABS);
5318     }
5319 
5320 
5321     static short NOT(short a) {
5322         return (short)(~((short)a));
5323     }
5324 
5325     static short not(short a) {
5326         return (short)(~((short)a));
5327     }
5328 
5329 
5330 
5331     @Test(dataProvider = "shortUnaryOpProvider")
5332     static void NOTShort256VectorTests(IntFunction<short[]> fa) {
5333         short[] a = fa.apply(SPECIES.length());
5334         short[] r = fr.apply(SPECIES.length());
5335 
5336         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5337             for (int i = 0; i < a.length; i += SPECIES.length()) {
5338                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5339                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
5340             }
5341         }
5342 
5343         assertArraysEquals(r, a, Short256VectorTests::NOT);
5344     }
5345 
5346     @Test(dataProvider = "shortUnaryOpProvider")
5347     static void notShort256VectorTests(IntFunction<short[]> fa) {
5348         short[] a = fa.apply(SPECIES.length());
5349         short[] r = fr.apply(SPECIES.length());
5350 
5351         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5352             for (int i = 0; i < a.length; i += SPECIES.length()) {
5353                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5354                 av.not().intoArray(r, i);
5355             }
5356         }
5357 
5358         assertArraysEquals(r, a, Short256VectorTests::not);
5359     }
5360 
5361 
5362 
5363     @Test(dataProvider = "shortUnaryOpMaskProvider")
5364     static void NOTMaskedShort256VectorTests(IntFunction<short[]> fa,
5365                                                 IntFunction<boolean[]> fm) {
5366         short[] a = fa.apply(SPECIES.length());
5367         short[] r = fr.apply(SPECIES.length());
5368         boolean[] mask = fm.apply(SPECIES.length());
5369         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5370 
5371         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5372             for (int i = 0; i < a.length; i += SPECIES.length()) {
5373                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5374                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
5375             }
5376         }
5377 
5378         assertArraysEquals(r, a, mask, Short256VectorTests::NOT);
5379     }
5380 
5381 
5382 
5383     static short ZOMO(short a) {
5384         return (short)((a==0?0:-1));
5385     }
5386 
5387 
5388 
5389     @Test(dataProvider = "shortUnaryOpProvider")
5390     static void ZOMOShort256VectorTests(IntFunction<short[]> fa) {
5391         short[] a = fa.apply(SPECIES.length());
5392         short[] r = fr.apply(SPECIES.length());
5393 
5394         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5395             for (int i = 0; i < a.length; i += SPECIES.length()) {
5396                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5397                 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
5398             }
5399         }
5400 
5401         assertArraysEquals(r, a, Short256VectorTests::ZOMO);
5402     }
5403 
5404 
5405 
5406     @Test(dataProvider = "shortUnaryOpMaskProvider")
5407     static void ZOMOMaskedShort256VectorTests(IntFunction<short[]> fa,
5408                                                 IntFunction<boolean[]> fm) {
5409         short[] a = fa.apply(SPECIES.length());
5410         short[] r = fr.apply(SPECIES.length());
5411         boolean[] mask = fm.apply(SPECIES.length());
5412         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5413 
5414         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5415             for (int i = 0; i < a.length; i += SPECIES.length()) {
5416                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5417                 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
5418             }
5419         }
5420 
5421         assertArraysEquals(r, a, mask, Short256VectorTests::ZOMO);
5422     }
5423 























































































































































5424 




5425 






5426 




















5427 
5428     @Test(dataProvider = "shortCompareOpProvider")
5429     static void ltShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5430         short[] a = fa.apply(SPECIES.length());
5431         short[] b = fb.apply(SPECIES.length());
5432 
5433         for (int i = 0; i < a.length; i += SPECIES.length()) {
5434             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5435             VectorMask<Short> mv = av.lt(b[i]);
5436 
5437             // Check results as part of computation.
5438             for (int j = 0; j < SPECIES.length(); j++) {
5439                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5440             }
5441         }
5442     }
5443 
5444     @Test(dataProvider = "shortCompareOpProvider")
5445     static void eqShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5446         short[] a = fa.apply(SPECIES.length());

5809             }
5810         }
5811         return i - idx;
5812     }
5813 
5814     @Test(dataProvider = "maskProvider")
5815     static void maskFirstTrueShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5816         boolean[] a = fa.apply(SPECIES.length());
5817         int[] r = new int[a.length];
5818 
5819         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5820             for (int i = 0; i < a.length; i += SPECIES.length()) {
5821                 var vmask = SPECIES.loadMask(a, i);
5822                 r[i] = vmask.firstTrue();
5823             }
5824         }
5825 
5826         assertMaskReductionArraysEquals(r, a, Short256VectorTests::maskFirstTrue);
5827     }
5828 

















5829     @DataProvider
5830     public static Object[][] longMaskProvider() {
5831         return new Object[][]{
5832                 {0xFFFFFFFFFFFFFFFFL},
5833                 {0x0000000000000000L},
5834                 {0x5555555555555555L},
5835                 {0x0123456789abcdefL},
5836         };
5837     }
5838 
5839     @Test(dataProvider = "longMaskProvider")
5840     static void maskFromToLongShort256VectorTestsSmokeTest(long inputLong) {
5841         var vmask = VectorMask.fromLong(SPECIES, inputLong);
5842         long outputLong = vmask.toLong();
5843         Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
5844     }
5845 
5846     @DataProvider
5847     public static Object[][] offsetProvider() {
5848         return new Object[][]{

5851                 {+1},
5852                 {+2},
5853                 {-2},
5854         };
5855     }
5856 
5857     @Test(dataProvider = "offsetProvider")
5858     static void indexInRangeShort256VectorTestsSmokeTest(int offset) {
5859         int limit = SPECIES.length() * BUFFER_REPS;
5860         for (int i = 0; i < limit; i += SPECIES.length()) {
5861             var actualMask = SPECIES.indexInRange(i + offset, limit);
5862             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5863             assert(actualMask.equals(expectedMask));
5864             for (int j = 0; j < SPECIES.length(); j++)  {
5865                 int index = i + j + offset;
5866                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5867             }
5868         }
5869     }
5870 














5871     @DataProvider
5872     public static Object[][] lengthProvider() {
5873         return new Object[][]{
5874                 {0},
5875                 {1},
5876                 {32},
5877                 {37},
5878                 {1024},
5879                 {1024+1},
5880                 {1024+5},
5881         };
5882     }
5883 
5884     @Test(dataProvider = "lengthProvider")
5885     static void loopBoundShort256VectorTestsSmokeTest(int length) {
5886         int actualLoopBound = SPECIES.loopBound(length);
5887         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5888         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5889     }
5890 








5891     @Test
5892     static void ElementSizeShort256VectorTestsSmokeTest() {
5893         ShortVector av = ShortVector.zero(SPECIES);
5894         int elsize = av.elementSize();
5895         Assert.assertEquals(elsize, Short.SIZE);
5896     }
5897 
5898     @Test
5899     static void VectorShapeShort256VectorTestsSmokeTest() {
5900         ShortVector av = ShortVector.zero(SPECIES);
5901         VectorShape vsh = av.shape();
5902         assert(vsh.equals(VectorShape.S_256_BIT));
5903     }
5904 
5905     @Test
5906     static void ShapeWithLanesShort256VectorTestsSmokeTest() {
5907         ShortVector av = ShortVector.zero(SPECIES);
5908         VectorShape vsh = av.shape();
5909         VectorSpecies species = vsh.withLanes(short.class);
5910         assert(species.equals(SPECIES));

5933         ShortVector av = ShortVector.zero(SPECIES);
5934         VectorSpecies species = av.species().withLanes(short.class);
5935         assert(species.equals(SPECIES));
5936     }
5937 
5938     @Test
5939     static void WithShapeShort256VectorTestsSmokeTest() {
5940         ShortVector av = ShortVector.zero(SPECIES);
5941         VectorShape vsh = av.shape();
5942         VectorSpecies species = av.species().withShape(vsh);
5943         assert(species.equals(SPECIES));
5944     }
5945 
5946     @Test
5947     static void MaskAllTrueShort256VectorTestsSmokeTest() {
5948         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5949           Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
5950         }
5951     }
5952 }
5953 

 244             } else {
 245                 Assert.assertEquals(r[i], a[i], "at index #" + i);
 246             }
 247         }
 248     }
 249 
 250     static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, int vector_len) {
 251         int i = 0, j = 0;
 252         try {
 253             for (; i < a.length; i += vector_len) {
 254                 for (j = 0; j < vector_len; j++) {
 255                     Assert.assertEquals(r[i+j], a[i+order[i+j]]);
 256                 }
 257             }
 258         } catch (AssertionError e) {
 259             int idx = i + j;
 260             Assert.assertEquals(r[i+j], a[i+order[i+j]], "at index #" + idx + ", input = " + a[i+order[i+j]]);
 261         }
 262     }
 263 
 264     static void assertcompressArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) {
 265         int i = 0, j = 0, k = 0;
 266         try {
 267             for (; i < a.length; i += vector_len) {
 268                 k = 0;
 269                 for (j = 0; j < vector_len; j++) {
 270                     if (m[(i + j) % SPECIES.length()]) {
 271                         Assert.assertEquals(r[i + k], a[i + j]);
 272                         k++;
 273                     }
 274                 }
 275                 for (; k < vector_len; k++) {
 276                     Assert.assertEquals(r[i + k], (short)0);
 277                 }
 278             }
 279         } catch (AssertionError e) {
 280             int idx = i + k;
 281             if (m[(i + j) % SPECIES.length()]) {
 282                 Assert.assertEquals(r[idx], a[i + j], "at index #" + idx);
 283             } else {
 284                 Assert.assertEquals(r[idx], (short)0, "at index #" + idx);
 285             }
 286         }
 287     }
 288 
 289     static void assertexpandArraysEquals(short[] r, short[] a, boolean[] m, int vector_len) {
 290         int i = 0, j = 0, k = 0;
 291         try {
 292             for (; i < a.length; i += vector_len) {
 293                 k = 0;
 294                 for (j = 0; j < vector_len; j++) {
 295                     if (m[(i + j) % SPECIES.length()]) {
 296                         Assert.assertEquals(r[i + j], a[i + k]);
 297                         k++;
 298                     } else {
 299                         Assert.assertEquals(r[i + j], (short)0);
 300                     }
 301                 }
 302             }
 303         } catch (AssertionError e) {
 304             int idx = i + j;
 305             if (m[idx % SPECIES.length()]) {
 306                 Assert.assertEquals(r[idx], a[i + k], "at index #" + idx);
 307             } else {
 308                 Assert.assertEquals(r[idx], (short)0, "at index #" + idx);
 309             }
 310         }
 311     }
 312 
 313     static void assertSelectFromArraysEquals(short[] r, short[] a, short[] order, int vector_len) {
 314         int i = 0, j = 0;
 315         try {
 316             for (; i < a.length; i += vector_len) {
 317                 for (j = 0; j < vector_len; j++) {
 318                     Assert.assertEquals(r[i+j], a[i+(int)order[i+j]]);
 319                 }
 320             }
 321         } catch (AssertionError e) {
 322             int idx = i + j;
 323             Assert.assertEquals(r[i+j], a[i+(int)order[i+j]], "at index #" + idx + ", input = " + a[i+(int)order[i+j]]);
 324         }
 325     }
 326 
 327     static void assertRearrangeArraysEquals(short[] r, short[] a, int[] order, boolean[] mask, int vector_len) {
 328         int i = 0, j = 0;
 329         try {
 330             for (; i < a.length; i += vector_len) {
 331                 for (j = 0; j < vector_len; j++) {
 332                     if (mask[j % SPECIES.length()])

 916         try {
 917             for (; i < r.length; i++) {
 918                 Assert.assertEquals(r[i], (long)(a[i+offs]));
 919             }
 920         } catch (AssertionError e) {
 921             Assert.assertEquals(r[i], (long)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 922         }
 923     }
 924 
 925     static void assertArraysEquals(double[] r, short[] a, int offs) {
 926         int i = 0;
 927         try {
 928             for (; i < r.length; i++) {
 929                 Assert.assertEquals(r[i], (double)(a[i+offs]));
 930             }
 931         } catch (AssertionError e) {
 932             Assert.assertEquals(r[i], (double)(a[i+offs]), "at index #" + i + ", input = " + a[i+offs]);
 933         }
 934     }
 935 

 936     static short bits(short e) {
 937         return  e;
 938     }
 939 
 940     static final List<IntFunction<short[]>> SHORT_GENERATORS = List.of(
 941             withToString("short[-i * 5]", (int s) -> {
 942                 return fill(s * BUFFER_REPS,
 943                             i -> (short)(-i * 5));
 944             }),
 945             withToString("short[i * 5]", (int s) -> {
 946                 return fill(s * BUFFER_REPS,
 947                             i -> (short)(i * 5));
 948             }),
 949             withToString("short[i + 1]", (int s) -> {
 950                 return fill(s * BUFFER_REPS,
 951                             i -> (((short)(i + 1) == 0) ? 1 : (short)(i + 1)));
 952             }),
 953             withToString("short[cornerCaseValue(i)]", (int s) -> {
 954                 return fill(s * BUFFER_REPS,
 955                             i -> cornerCaseValue(i));

1010                 })).
1011                 toArray(Object[][]::new);
1012     }
1013 
1014     @DataProvider
1015     public Object[][] shortUnaryOpProvider() {
1016         return SHORT_GENERATORS.stream().
1017                 map(f -> new Object[]{f}).
1018                 toArray(Object[][]::new);
1019     }
1020 
1021     @DataProvider
1022     public Object[][] shortUnaryOpMaskProvider() {
1023         return BOOLEAN_MASK_GENERATORS.stream().
1024                 flatMap(fm -> SHORT_GENERATORS.stream().map(fa -> {
1025                     return new Object[] {fa, fm};
1026                 })).
1027                 toArray(Object[][]::new);
1028     }
1029 


1030     @DataProvider
1031     public Object[][] maskProvider() {
1032         return BOOLEAN_MASK_GENERATORS.stream().
1033                 map(f -> new Object[]{f}).
1034                 toArray(Object[][]::new);
1035     }
1036 
1037     @DataProvider
1038     public Object[][] maskCompareOpProvider() {
1039         return BOOLEAN_MASK_COMPARE_GENERATOR_PAIRS.stream().map(List::toArray).
1040                 toArray(Object[][]::new);
1041     }
1042 
1043     @DataProvider
1044     public Object[][] shuffleProvider() {
1045         return INT_SHUFFLE_GENERATORS.stream().
1046                 map(f -> new Object[]{f}).
1047                 toArray(Object[][]::new);
1048     }
1049 

1085 
1086     @DataProvider
1087     public Object[][] shortUnaryOpSelectFromProvider() {
1088         return SHORT_SHUFFLE_GENERATORS.stream().
1089                 flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1090                     return new Object[] {fa, fs};
1091                 })).
1092                 toArray(Object[][]::new);
1093     }
1094 
1095     @DataProvider
1096     public Object[][] shortUnaryOpSelectFromMaskProvider() {
1097         return BOOLEAN_MASK_GENERATORS.stream().
1098                 flatMap(fm -> SHORT_SHUFFLE_GENERATORS.stream().
1099                     flatMap(fs -> SHORT_GENERATORS.stream().map(fa -> {
1100                         return new Object[] {fa, fs, fm};
1101                 }))).
1102                 toArray(Object[][]::new);
1103     }
1104 

1105     static final List<IntFunction<short[]>> SHORT_COMPARE_GENERATORS = List.of(
1106             withToString("short[i]", (int s) -> {
1107                 return fill(s * BUFFER_REPS,
1108                             i -> (short)i);
1109             }),
1110             withToString("short[i - length / 2]", (int s) -> {
1111                 return fill(s * BUFFER_REPS,
1112                             i -> (short)(i - (s * BUFFER_REPS / 2)));
1113             }),
1114             withToString("short[i + 1]", (int s) -> {
1115                 return fill(s * BUFFER_REPS,
1116                             i -> (short)(i + 1));
1117             }),
1118             withToString("short[i - 2]", (int s) -> {
1119                 return fill(s * BUFFER_REPS,
1120                             i -> (short)(i - 2));
1121             }),
1122             withToString("short[zigZag(i)]", (int s) -> {
1123                 return fill(s * BUFFER_REPS,
1124                             i -> i%3 == 0 ? (short)i : (i%3 == 1 ? (short)(i + 1) : (short)(i - 2)));

1225             }
1226         }
1227     }
1228 
1229     static void replaceZero(short[] a, boolean[] mask, short v) {
1230         for (int i = 0; i < a.length; i++) {
1231             if (mask[i % mask.length] && a[i] == 0) {
1232                 a[i] = v;
1233             }
1234         }
1235     }
1236 
1237     static short ROL_scalar(short a, short b) {
1238         return (short)(((((short)a) & 0xFFFF) << (b & 15)) | ((((short)a) & 0xFFFF) >>> (16 - (b & 15))));
1239     }
1240 
1241     static short ROR_scalar(short a, short b) {
1242         return (short)(((((short)a) & 0xFFFF) >>> (b & 15)) | ((((short)a) & 0xFFFF) << (16 - (b & 15))));
1243     }
1244 
1245     static short TRAILING_ZEROS_COUNT_scalar(short a) {
1246         return (short) (a != 0 ? Integer.numberOfTrailingZeros(a) : 16);
1247     }
1248 
1249     static short LEADING_ZEROS_COUNT_scalar(short a) {
1250         return (short) (a >= 0 ? Integer.numberOfLeadingZeros(a) - 16 : 0);
1251     }
1252 
1253     static short REVERSE_scalar(short a) {
1254         short b = ROL_scalar(a, (short) 8);
1255         b = (short) (((b & 0x5555) << 1) | ((b & 0xAAAA) >>> 1));
1256         b = (short) (((b & 0x3333) << 2) | ((b & 0xCCCC) >>> 2));
1257         b = (short) (((b & 0x0F0F) << 4) | ((b & 0xF0F0) >>> 4));
1258         return b;
1259     }
1260 
1261     static boolean eq(short a, short b) {
1262         return a == b;
1263     }
1264 
1265     static boolean neq(short a, short b) {
1266         return a != b;
1267     }
1268 
1269     static boolean lt(short a, short b) {
1270         return a < b;
1271     }
1272 
1273     static boolean le(short a, short b) {
1274         return a <= b;
1275     }
1276 
1277     static boolean gt(short a, short b) {
1278         return a > b;
1279     }
1280 

1390     @Test
1391     // Test div by 0.
1392     static void bitwiseDivByZeroSmokeTest() {
1393         try {
1394             ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1395             ShortVector b = (ShortVector) SPECIES.broadcast(0);
1396             a.div(b);
1397             Assert.fail();
1398         } catch (ArithmeticException e) {
1399         }
1400 
1401         try {
1402             ShortVector a = (ShortVector) SPECIES.broadcast(0).addIndex(1);
1403             ShortVector b = (ShortVector) SPECIES.broadcast(0);
1404             VectorMask<Short> m = a.lt((short) 1);
1405             a.div(b, m);
1406             Assert.fail();
1407         } catch (ArithmeticException e) {
1408         }
1409     }
1410 
1411     static short ADD(short a, short b) {
1412         return (short)(a + b);
1413     }
1414 
1415     @Test(dataProvider = "shortBinaryOpProvider")
1416     static void ADDShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1417         short[] a = fa.apply(SPECIES.length());
1418         short[] b = fb.apply(SPECIES.length());
1419         short[] r = fr.apply(SPECIES.length());
1420 
1421         for (int ic = 0; ic < INVOC_COUNT; ic++) {
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.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1426             }
1427         }
1428 
1429         assertArraysEquals(r, a, b, Short256VectorTests::ADD);
1430     }
1431 
1432     static short add(short a, short b) {
1433         return (short)(a + b);
1434     }
1435 
1436     @Test(dataProvider = "shortBinaryOpProvider")
1437     static void addShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1438         short[] a = fa.apply(SPECIES.length());
1439         short[] b = fb.apply(SPECIES.length());
1440         short[] r = fr.apply(SPECIES.length());
1441 
1442         for (int i = 0; i < a.length; i += SPECIES.length()) {
1443             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1444             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1445             av.add(bv).intoArray(r, i);
1446         }
1447 
1448         assertArraysEquals(r, a, b, Short256VectorTests::add);
1449     }
1450 
1451     @Test(dataProvider = "shortBinaryOpMaskProvider")

1468         assertArraysEquals(r, a, b, mask, Short256VectorTests::ADD);
1469     }
1470 
1471     @Test(dataProvider = "shortBinaryOpMaskProvider")
1472     static void addShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1473                                           IntFunction<boolean[]> fm) {
1474         short[] a = fa.apply(SPECIES.length());
1475         short[] b = fb.apply(SPECIES.length());
1476         short[] r = fr.apply(SPECIES.length());
1477         boolean[] mask = fm.apply(SPECIES.length());
1478         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1479 
1480         for (int i = 0; i < a.length; i += SPECIES.length()) {
1481             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1482             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1483             av.add(bv, vmask).intoArray(r, i);
1484         }
1485 
1486         assertArraysEquals(r, a, b, mask, Short256VectorTests::add);
1487     }
1488 
1489     static short SUB(short a, short b) {
1490         return (short)(a - b);
1491     }
1492 
1493     @Test(dataProvider = "shortBinaryOpProvider")
1494     static void SUBShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1495         short[] a = fa.apply(SPECIES.length());
1496         short[] b = fb.apply(SPECIES.length());
1497         short[] r = fr.apply(SPECIES.length());
1498 
1499         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1500             for (int i = 0; i < a.length; i += SPECIES.length()) {
1501                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1502                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1503                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1504             }
1505         }
1506 
1507         assertArraysEquals(r, a, b, Short256VectorTests::SUB);
1508     }
1509 
1510     static short sub(short a, short b) {
1511         return (short)(a - b);
1512     }
1513 
1514     @Test(dataProvider = "shortBinaryOpProvider")
1515     static void subShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1516         short[] a = fa.apply(SPECIES.length());
1517         short[] b = fb.apply(SPECIES.length());
1518         short[] r = fr.apply(SPECIES.length());
1519 
1520         for (int i = 0; i < a.length; i += SPECIES.length()) {
1521             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1522             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1523             av.sub(bv).intoArray(r, i);
1524         }
1525 
1526         assertArraysEquals(r, a, b, Short256VectorTests::sub);
1527     }
1528 
1529     @Test(dataProvider = "shortBinaryOpMaskProvider")

1546         assertArraysEquals(r, a, b, mask, Short256VectorTests::SUB);
1547     }
1548 
1549     @Test(dataProvider = "shortBinaryOpMaskProvider")
1550     static void subShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1551                                           IntFunction<boolean[]> fm) {
1552         short[] a = fa.apply(SPECIES.length());
1553         short[] b = fb.apply(SPECIES.length());
1554         short[] r = fr.apply(SPECIES.length());
1555         boolean[] mask = fm.apply(SPECIES.length());
1556         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1557 
1558         for (int i = 0; i < a.length; i += SPECIES.length()) {
1559             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1560             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1561             av.sub(bv, vmask).intoArray(r, i);
1562         }
1563 
1564         assertArraysEquals(r, a, b, mask, Short256VectorTests::sub);
1565     }
1566 
1567     static short MUL(short a, short b) {
1568         return (short)(a * b);
1569     }
1570 
1571     @Test(dataProvider = "shortBinaryOpProvider")
1572     static void MULShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1573         short[] a = fa.apply(SPECIES.length());
1574         short[] b = fb.apply(SPECIES.length());
1575         short[] r = fr.apply(SPECIES.length());
1576 
1577         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1578             for (int i = 0; i < a.length; i += SPECIES.length()) {
1579                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1580                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1581                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1582             }
1583         }
1584 
1585         assertArraysEquals(r, a, b, Short256VectorTests::MUL);
1586     }
1587 
1588     static short mul(short a, short b) {
1589         return (short)(a * b);
1590     }
1591 
1592     @Test(dataProvider = "shortBinaryOpProvider")
1593     static void mulShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1594         short[] a = fa.apply(SPECIES.length());
1595         short[] b = fb.apply(SPECIES.length());
1596         short[] r = fr.apply(SPECIES.length());
1597 
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.mul(bv).intoArray(r, i);
1602         }
1603 
1604         assertArraysEquals(r, a, b, Short256VectorTests::mul);
1605     }
1606 
1607     @Test(dataProvider = "shortBinaryOpMaskProvider")

1625     }
1626 
1627     @Test(dataProvider = "shortBinaryOpMaskProvider")
1628     static void mulShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1629                                           IntFunction<boolean[]> fm) {
1630         short[] a = fa.apply(SPECIES.length());
1631         short[] b = fb.apply(SPECIES.length());
1632         short[] r = fr.apply(SPECIES.length());
1633         boolean[] mask = fm.apply(SPECIES.length());
1634         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1635 
1636         for (int i = 0; i < a.length; i += SPECIES.length()) {
1637             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1638             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1639             av.mul(bv, vmask).intoArray(r, i);
1640         }
1641 
1642         assertArraysEquals(r, a, b, mask, Short256VectorTests::mul);
1643     }
1644 


1645     static short DIV(short a, short b) {
1646         return (short)(a / b);
1647     }
1648 
1649     @Test(dataProvider = "shortBinaryOpProvider")
1650     static void DIVShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1651         short[] a = fa.apply(SPECIES.length());
1652         short[] b = fb.apply(SPECIES.length());
1653         short[] r = fr.apply(SPECIES.length());
1654 
1655         replaceZero(b, (short) 1);
1656 
1657         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1658             for (int i = 0; i < a.length; i += SPECIES.length()) {
1659                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1660                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1661                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1662             }
1663         }
1664 
1665         assertArraysEquals(r, a, b, Short256VectorTests::DIV);
1666     }
1667 
1668     static short div(short a, short b) {
1669         return (short)(a / b);
1670     }
1671 
1672     @Test(dataProvider = "shortBinaryOpProvider")
1673     static void divShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1674         short[] a = fa.apply(SPECIES.length());
1675         short[] b = fb.apply(SPECIES.length());
1676         short[] r = fr.apply(SPECIES.length());
1677 
1678         replaceZero(b, (short) 1);
1679 
1680         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1681             for (int i = 0; i < a.length; i += SPECIES.length()) {
1682                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1683                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1684                 av.div(bv).intoArray(r, i);
1685             }
1686         }
1687 
1688         assertArraysEquals(r, a, b, Short256VectorTests::div);
1689     }
1690 


1691     @Test(dataProvider = "shortBinaryOpMaskProvider")
1692     static void DIVShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1693                                           IntFunction<boolean[]> fm) {
1694         short[] a = fa.apply(SPECIES.length());
1695         short[] b = fb.apply(SPECIES.length());
1696         short[] r = fr.apply(SPECIES.length());
1697         boolean[] mask = fm.apply(SPECIES.length());
1698         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1699 
1700         replaceZero(b, mask, (short) 1);
1701 
1702         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1703             for (int i = 0; i < a.length; i += SPECIES.length()) {
1704                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1705                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1706                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1707             }
1708         }
1709 
1710         assertArraysEquals(r, a, b, mask, Short256VectorTests::DIV);

1776     static short AND(short a, short b) {
1777         return (short)(a & b);
1778     }
1779 
1780     @Test(dataProvider = "shortBinaryOpProvider")
1781     static void ANDShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1782         short[] a = fa.apply(SPECIES.length());
1783         short[] b = fb.apply(SPECIES.length());
1784         short[] r = fr.apply(SPECIES.length());
1785 
1786         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1787             for (int i = 0; i < a.length; i += SPECIES.length()) {
1788                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1789                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1790                 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1791             }
1792         }
1793 
1794         assertArraysEquals(r, a, b, Short256VectorTests::AND);
1795     }
1796 
1797     static short and(short a, short b) {
1798         return (short)(a & b);
1799     }
1800 
1801     @Test(dataProvider = "shortBinaryOpProvider")
1802     static void andShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1803         short[] a = fa.apply(SPECIES.length());
1804         short[] b = fb.apply(SPECIES.length());
1805         short[] r = fr.apply(SPECIES.length());
1806 
1807         for (int i = 0; i < a.length; i += SPECIES.length()) {
1808             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1809             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1810             av.and(bv).intoArray(r, i);
1811         }
1812 
1813         assertArraysEquals(r, a, b, Short256VectorTests::and);
1814     }
1815 


1816     @Test(dataProvider = "shortBinaryOpMaskProvider")
1817     static void ANDShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1818                                           IntFunction<boolean[]> fm) {
1819         short[] a = fa.apply(SPECIES.length());
1820         short[] b = fb.apply(SPECIES.length());
1821         short[] r = fr.apply(SPECIES.length());
1822         boolean[] mask = fm.apply(SPECIES.length());
1823         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1824 
1825         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1826             for (int i = 0; i < a.length; i += SPECIES.length()) {
1827                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1828                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1829                 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
1830             }
1831         }
1832 
1833         assertArraysEquals(r, a, b, mask, Short256VectorTests::AND);
1834     }
1835 

1836     static short AND_NOT(short a, short b) {
1837         return (short)(a & ~b);
1838     }
1839 
1840     @Test(dataProvider = "shortBinaryOpProvider")
1841     static void AND_NOTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1842         short[] a = fa.apply(SPECIES.length());
1843         short[] b = fb.apply(SPECIES.length());
1844         short[] r = fr.apply(SPECIES.length());
1845 
1846         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1847             for (int i = 0; i < a.length; i += SPECIES.length()) {
1848                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1849                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1850                 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
1851             }
1852         }
1853 
1854         assertArraysEquals(r, a, b, Short256VectorTests::AND_NOT);
1855     }
1856 


1857     @Test(dataProvider = "shortBinaryOpMaskProvider")
1858     static void AND_NOTShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1859                                           IntFunction<boolean[]> fm) {
1860         short[] a = fa.apply(SPECIES.length());
1861         short[] b = fb.apply(SPECIES.length());
1862         short[] r = fr.apply(SPECIES.length());
1863         boolean[] mask = fm.apply(SPECIES.length());
1864         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1865 
1866         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1867             for (int i = 0; i < a.length; i += SPECIES.length()) {
1868                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1869                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1870                 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
1871             }
1872         }
1873 
1874         assertArraysEquals(r, a, b, mask, Short256VectorTests::AND_NOT);
1875     }
1876 

1877     static short OR(short a, short b) {
1878         return (short)(a | b);
1879     }
1880 
1881     @Test(dataProvider = "shortBinaryOpProvider")
1882     static void ORShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1883         short[] a = fa.apply(SPECIES.length());
1884         short[] b = fb.apply(SPECIES.length());
1885         short[] r = fr.apply(SPECIES.length());
1886 
1887         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1888             for (int i = 0; i < a.length; i += SPECIES.length()) {
1889                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1890                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1891                 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1892             }
1893         }
1894 
1895         assertArraysEquals(r, a, b, Short256VectorTests::OR);
1896     }
1897 
1898     static short or(short a, short b) {
1899         return (short)(a | b);
1900     }
1901 
1902     @Test(dataProvider = "shortBinaryOpProvider")
1903     static void orShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1904         short[] a = fa.apply(SPECIES.length());
1905         short[] b = fb.apply(SPECIES.length());
1906         short[] r = fr.apply(SPECIES.length());
1907 
1908         for (int i = 0; i < a.length; i += SPECIES.length()) {
1909             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1910             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1911             av.or(bv).intoArray(r, i);
1912         }
1913 
1914         assertArraysEquals(r, a, b, Short256VectorTests::or);
1915     }
1916 


1917     @Test(dataProvider = "shortBinaryOpMaskProvider")
1918     static void ORShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1919                                           IntFunction<boolean[]> fm) {
1920         short[] a = fa.apply(SPECIES.length());
1921         short[] b = fb.apply(SPECIES.length());
1922         short[] r = fr.apply(SPECIES.length());
1923         boolean[] mask = fm.apply(SPECIES.length());
1924         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1925 
1926         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1927             for (int i = 0; i < a.length; i += SPECIES.length()) {
1928                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1929                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1930                 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1931             }
1932         }
1933 
1934         assertArraysEquals(r, a, b, mask, Short256VectorTests::OR);
1935     }
1936 

1937     static short XOR(short a, short b) {
1938         return (short)(a ^ b);
1939     }
1940 
1941     @Test(dataProvider = "shortBinaryOpProvider")
1942     static void XORShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1943         short[] a = fa.apply(SPECIES.length());
1944         short[] b = fb.apply(SPECIES.length());
1945         short[] r = fr.apply(SPECIES.length());
1946 
1947         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1948             for (int i = 0; i < a.length; i += SPECIES.length()) {
1949                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1950                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1951                 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
1952             }
1953         }
1954 
1955         assertArraysEquals(r, a, b, Short256VectorTests::XOR);
1956     }
1957 


1958     @Test(dataProvider = "shortBinaryOpMaskProvider")
1959     static void XORShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
1960                                           IntFunction<boolean[]> fm) {
1961         short[] a = fa.apply(SPECIES.length());
1962         short[] b = fb.apply(SPECIES.length());
1963         short[] r = fr.apply(SPECIES.length());
1964         boolean[] mask = fm.apply(SPECIES.length());
1965         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1966 
1967         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1968             for (int i = 0; i < a.length; i += SPECIES.length()) {
1969                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1970                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
1971                 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1972             }
1973         }
1974 
1975         assertArraysEquals(r, a, b, mask, Short256VectorTests::XOR);
1976     }
1977 

1978     @Test(dataProvider = "shortBinaryOpProvider")
1979     static void addShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
1980         short[] a = fa.apply(SPECIES.length());
1981         short[] b = fb.apply(SPECIES.length());
1982         short[] r = fr.apply(SPECIES.length());
1983 
1984         for (int i = 0; i < a.length; i += SPECIES.length()) {
1985             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
1986             av.add(b[i]).intoArray(r, i);
1987         }
1988 
1989         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::add);
1990     }
1991 
1992     @Test(dataProvider = "shortBinaryOpMaskProvider")
1993     static void addShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
1994                                           IntFunction<boolean[]> fm) {
1995         short[] a = fa.apply(SPECIES.length());
1996         short[] b = fb.apply(SPECIES.length());
1997         short[] r = fr.apply(SPECIES.length());

2051         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::mul);
2052     }
2053 
2054     @Test(dataProvider = "shortBinaryOpMaskProvider")
2055     static void mulShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2056                                           IntFunction<boolean[]> fm) {
2057         short[] a = fa.apply(SPECIES.length());
2058         short[] b = fb.apply(SPECIES.length());
2059         short[] r = fr.apply(SPECIES.length());
2060         boolean[] mask = fm.apply(SPECIES.length());
2061         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2062 
2063         for (int i = 0; i < a.length; i += SPECIES.length()) {
2064             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2065             av.mul(b[i], vmask).intoArray(r, i);
2066         }
2067 
2068         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::mul);
2069     }
2070 



2071     @Test(dataProvider = "shortBinaryOpProvider")
2072     static void divShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2073         short[] a = fa.apply(SPECIES.length());
2074         short[] b = fb.apply(SPECIES.length());
2075         short[] r = fr.apply(SPECIES.length());
2076 
2077         replaceZero(b, (short) 1);
2078 
2079         for (int i = 0; i < a.length; i += SPECIES.length()) {
2080             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2081             av.div(b[i]).intoArray(r, i);
2082         }
2083 
2084         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::div);
2085     }
2086 


2087     @Test(dataProvider = "shortBinaryOpMaskProvider")
2088     static void divShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2089                                           IntFunction<boolean[]> fm) {
2090         short[] a = fa.apply(SPECIES.length());
2091         short[] b = fb.apply(SPECIES.length());
2092         short[] r = fr.apply(SPECIES.length());
2093         boolean[] mask = fm.apply(SPECIES.length());
2094         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2095 
2096         replaceZero(b, (short) 1);
2097 
2098         for (int i = 0; i < a.length; i += SPECIES.length()) {
2099             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2100             av.div(b[i], vmask).intoArray(r, i);
2101         }
2102 
2103         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::div);
2104     }
2105 


2106     @Test(dataProvider = "shortBinaryOpProvider")
2107     static void ORShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2108         short[] a = fa.apply(SPECIES.length());
2109         short[] b = fb.apply(SPECIES.length());
2110         short[] r = fr.apply(SPECIES.length());
2111 
2112         for (int i = 0; i < a.length; i += SPECIES.length()) {
2113             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2114             av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2115         }
2116 
2117         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::OR);
2118     }
2119 
2120     @Test(dataProvider = "shortBinaryOpProvider")
2121     static void orShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2122         short[] a = fa.apply(SPECIES.length());
2123         short[] b = fb.apply(SPECIES.length());
2124         short[] r = fr.apply(SPECIES.length());
2125 
2126         for (int i = 0; i < a.length; i += SPECIES.length()) {
2127             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2128             av.or(b[i]).intoArray(r, i);
2129         }
2130 
2131         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::or);
2132     }
2133 


2134     @Test(dataProvider = "shortBinaryOpMaskProvider")
2135     static void ORShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2136                                           IntFunction<boolean[]> fm) {
2137         short[] a = fa.apply(SPECIES.length());
2138         short[] b = fb.apply(SPECIES.length());
2139         short[] r = fr.apply(SPECIES.length());
2140         boolean[] mask = fm.apply(SPECIES.length());
2141         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2142 
2143         for (int i = 0; i < a.length; i += SPECIES.length()) {
2144             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2145             av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2146         }
2147 
2148         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::OR);
2149     }
2150 


2151     @Test(dataProvider = "shortBinaryOpProvider")
2152     static void ANDShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2153         short[] a = fa.apply(SPECIES.length());
2154         short[] b = fb.apply(SPECIES.length());
2155         short[] r = fr.apply(SPECIES.length());
2156 
2157         for (int i = 0; i < a.length; i += SPECIES.length()) {
2158             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2159             av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2160         }
2161 
2162         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::AND);
2163     }
2164 
2165     @Test(dataProvider = "shortBinaryOpProvider")
2166     static void andShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2167         short[] a = fa.apply(SPECIES.length());
2168         short[] b = fb.apply(SPECIES.length());
2169         short[] r = fr.apply(SPECIES.length());
2170 
2171         for (int i = 0; i < a.length; i += SPECIES.length()) {
2172             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2173             av.and(b[i]).intoArray(r, i);
2174         }
2175 
2176         assertBroadcastArraysEquals(r, a, b, Short256VectorTests::and);
2177     }
2178 


2179     @Test(dataProvider = "shortBinaryOpMaskProvider")
2180     static void ANDShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2181                                           IntFunction<boolean[]> fm) {
2182         short[] a = fa.apply(SPECIES.length());
2183         short[] b = fb.apply(SPECIES.length());
2184         short[] r = fr.apply(SPECIES.length());
2185         boolean[] mask = fm.apply(SPECIES.length());
2186         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2187 
2188         for (int i = 0; i < a.length; i += SPECIES.length()) {
2189             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2190             av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2191         }
2192 
2193         assertBroadcastArraysEquals(r, a, b, mask, Short256VectorTests::AND);
2194     }
2195 


2196     @Test(dataProvider = "shortBinaryOpProvider")
2197     static void ORShort256VectorTestsBroadcastLongSmokeTest(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.OR, (long)b[i]).intoArray(r, i);
2205         }
2206 
2207         assertBroadcastLongArraysEquals(r, a, b, Short256VectorTests::OR);
2208     }
2209 


2210     @Test(dataProvider = "shortBinaryOpMaskProvider")
2211     static void ORShort256VectorTestsBroadcastMaskedLongSmokeTest(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.OR, (long)b[i], vmask).intoArray(r, i);
2222         }
2223 
2224         assertBroadcastLongArraysEquals(r, a, b, mask, Short256VectorTests::OR);
2225     }
2226 

2227     @Test(dataProvider = "shortBinaryOpProvider")
2228     static void ADDShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2229         short[] a = fa.apply(SPECIES.length());
2230         short[] b = fb.apply(SPECIES.length());
2231         short[] r = fr.apply(SPECIES.length());
2232 
2233         for (int i = 0; i < a.length; i += SPECIES.length()) {
2234             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2235             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2236         }
2237 
2238         assertBroadcastLongArraysEquals(r, a, b, Short256VectorTests::ADD);
2239     }
2240 
2241     @Test(dataProvider = "shortBinaryOpMaskProvider")
2242     static void ADDShort256VectorTestsBroadcastMaskedLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
2243                                           IntFunction<boolean[]> fm) {
2244         short[] a = fa.apply(SPECIES.length());
2245         short[] b = fb.apply(SPECIES.length());
2246         short[] r = fr.apply(SPECIES.length());
2247         boolean[] mask = fm.apply(SPECIES.length());
2248         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2249 
2250         for (int i = 0; i < a.length; i += SPECIES.length()) {
2251             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2252             av.lanewise(VectorOperators.ADD, (long)b[i], vmask).intoArray(r, i);
2253         }
2254 
2255         assertBroadcastLongArraysEquals(r, a, b, mask, Short256VectorTests::ADD);
2256     }
2257 




2258     static short LSHL(short a, short b) {
2259         return (short)((a << (b & 0xF)));
2260     }
2261 
2262     @Test(dataProvider = "shortBinaryOpProvider")
2263     static void LSHLShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2264         short[] a = fa.apply(SPECIES.length());
2265         short[] b = fb.apply(SPECIES.length());
2266         short[] r = fr.apply(SPECIES.length());
2267 
2268         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2269             for (int i = 0; i < a.length; i += SPECIES.length()) {
2270                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2271                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2272                 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2273             }
2274         }
2275 
2276         assertArraysEquals(r, a, b, Short256VectorTests::LSHL);
2277     }
2278 


2279     @Test(dataProvider = "shortBinaryOpMaskProvider")
2280     static void LSHLShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2281                                           IntFunction<boolean[]> fm) {
2282         short[] a = fa.apply(SPECIES.length());
2283         short[] b = fb.apply(SPECIES.length());
2284         short[] r = fr.apply(SPECIES.length());
2285         boolean[] mask = fm.apply(SPECIES.length());
2286         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2287 
2288         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2289             for (int i = 0; i < a.length; i += SPECIES.length()) {
2290                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2291                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2292                 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2293             }
2294         }
2295 
2296         assertArraysEquals(r, a, b, mask, Short256VectorTests::LSHL);
2297     }
2298 





2299     static short ASHR(short a, short b) {
2300         return (short)((a >> (b & 0xF)));
2301     }
2302 
2303     @Test(dataProvider = "shortBinaryOpProvider")
2304     static void ASHRShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2305         short[] a = fa.apply(SPECIES.length());
2306         short[] b = fb.apply(SPECIES.length());
2307         short[] r = fr.apply(SPECIES.length());
2308 
2309         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2310             for (int i = 0; i < a.length; i += SPECIES.length()) {
2311                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2312                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2313                 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2314             }
2315         }
2316 
2317         assertArraysEquals(r, a, b, Short256VectorTests::ASHR);
2318     }
2319 


2320     @Test(dataProvider = "shortBinaryOpMaskProvider")
2321     static void ASHRShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2322                                           IntFunction<boolean[]> fm) {
2323         short[] a = fa.apply(SPECIES.length());
2324         short[] b = fb.apply(SPECIES.length());
2325         short[] r = fr.apply(SPECIES.length());
2326         boolean[] mask = fm.apply(SPECIES.length());
2327         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2328 
2329         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2330             for (int i = 0; i < a.length; i += SPECIES.length()) {
2331                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2332                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2333                 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2334             }
2335         }
2336 
2337         assertArraysEquals(r, a, b, mask, Short256VectorTests::ASHR);
2338     }
2339 





2340     static short LSHR(short a, short b) {
2341         return (short)(((a & 0xFFFF) >>> (b & 0xF)));
2342     }
2343 
2344     @Test(dataProvider = "shortBinaryOpProvider")
2345     static void LSHRShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2346         short[] a = fa.apply(SPECIES.length());
2347         short[] b = fb.apply(SPECIES.length());
2348         short[] r = fr.apply(SPECIES.length());
2349 
2350         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2351             for (int i = 0; i < a.length; i += SPECIES.length()) {
2352                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2353                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2354                 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2355             }
2356         }
2357 
2358         assertArraysEquals(r, a, b, Short256VectorTests::LSHR);
2359     }
2360 


2361     @Test(dataProvider = "shortBinaryOpMaskProvider")
2362     static void LSHRShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2363                                           IntFunction<boolean[]> fm) {
2364         short[] a = fa.apply(SPECIES.length());
2365         short[] b = fb.apply(SPECIES.length());
2366         short[] r = fr.apply(SPECIES.length());
2367         boolean[] mask = fm.apply(SPECIES.length());
2368         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2369 
2370         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2371             for (int i = 0; i < a.length; i += SPECIES.length()) {
2372                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2373                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2374                 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2375             }
2376         }
2377 
2378         assertArraysEquals(r, a, b, mask, Short256VectorTests::LSHR);
2379     }
2380 





2381     static short LSHL_unary(short a, short b) {
2382         return (short)((a << (b & 15)));
2383     }
2384 
2385     @Test(dataProvider = "shortBinaryOpProvider")
2386     static void LSHLShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2387         short[] a = fa.apply(SPECIES.length());
2388         short[] b = fb.apply(SPECIES.length());
2389         short[] r = fr.apply(SPECIES.length());
2390 
2391         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2392             for (int i = 0; i < a.length; i += SPECIES.length()) {
2393                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2394                 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2395             }
2396         }
2397 
2398         assertShiftArraysEquals(r, a, b, Short256VectorTests::LSHL_unary);
2399     }
2400 


2401     @Test(dataProvider = "shortBinaryOpMaskProvider")
2402     static void LSHLShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2403                                           IntFunction<boolean[]> fm) {
2404         short[] a = fa.apply(SPECIES.length());
2405         short[] b = fb.apply(SPECIES.length());
2406         short[] r = fr.apply(SPECIES.length());
2407         boolean[] mask = fm.apply(SPECIES.length());
2408         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2409 
2410         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2411             for (int i = 0; i < a.length; i += SPECIES.length()) {
2412                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2413                 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2414             }
2415         }
2416 
2417         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::LSHL_unary);
2418     }
2419 





2420     static short LSHR_unary(short a, short b) {
2421         return (short)(((a & 0xFFFF) >>> (b & 15)));
2422     }
2423 
2424     @Test(dataProvider = "shortBinaryOpProvider")
2425     static void LSHRShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2426         short[] a = fa.apply(SPECIES.length());
2427         short[] b = fb.apply(SPECIES.length());
2428         short[] r = fr.apply(SPECIES.length());
2429 
2430         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2431             for (int i = 0; i < a.length; i += SPECIES.length()) {
2432                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2433                 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2434             }
2435         }
2436 
2437         assertShiftArraysEquals(r, a, b, Short256VectorTests::LSHR_unary);
2438     }
2439 


2440     @Test(dataProvider = "shortBinaryOpMaskProvider")
2441     static void LSHRShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2442                                           IntFunction<boolean[]> fm) {
2443         short[] a = fa.apply(SPECIES.length());
2444         short[] b = fb.apply(SPECIES.length());
2445         short[] r = fr.apply(SPECIES.length());
2446         boolean[] mask = fm.apply(SPECIES.length());
2447         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2448 
2449         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2450             for (int i = 0; i < a.length; i += SPECIES.length()) {
2451                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2452                 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2453             }
2454         }
2455 
2456         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::LSHR_unary);
2457     }
2458 





2459     static short ASHR_unary(short a, short b) {
2460         return (short)((a >> (b & 15)));
2461     }
2462 
2463     @Test(dataProvider = "shortBinaryOpProvider")
2464     static void ASHRShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2465         short[] a = fa.apply(SPECIES.length());
2466         short[] b = fb.apply(SPECIES.length());
2467         short[] r = fr.apply(SPECIES.length());
2468 
2469         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2470             for (int i = 0; i < a.length; i += SPECIES.length()) {
2471                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2472                 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2473             }
2474         }
2475 
2476         assertShiftArraysEquals(r, a, b, Short256VectorTests::ASHR_unary);
2477     }
2478 


2479     @Test(dataProvider = "shortBinaryOpMaskProvider")
2480     static void ASHRShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2481                                           IntFunction<boolean[]> fm) {
2482         short[] a = fa.apply(SPECIES.length());
2483         short[] b = fb.apply(SPECIES.length());
2484         short[] r = fr.apply(SPECIES.length());
2485         boolean[] mask = fm.apply(SPECIES.length());
2486         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2487 
2488         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2489             for (int i = 0; i < a.length; i += SPECIES.length()) {
2490                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2491                 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2492             }
2493         }
2494 
2495         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ASHR_unary);
2496     }
2497 

2498     static short ROR(short a, short b) {
2499         return (short)(ROR_scalar(a,b));
2500     }
2501 
2502     @Test(dataProvider = "shortBinaryOpProvider")
2503     static void RORShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2504         short[] a = fa.apply(SPECIES.length());
2505         short[] b = fb.apply(SPECIES.length());
2506         short[] r = fr.apply(SPECIES.length());
2507 
2508         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2509             for (int i = 0; i < a.length; i += SPECIES.length()) {
2510                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2511                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2512                 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2513             }
2514         }
2515 
2516         assertArraysEquals(r, a, b, Short256VectorTests::ROR);
2517     }
2518 


2519     @Test(dataProvider = "shortBinaryOpMaskProvider")
2520     static void RORShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2521                                           IntFunction<boolean[]> fm) {
2522         short[] a = fa.apply(SPECIES.length());
2523         short[] b = fb.apply(SPECIES.length());
2524         short[] r = fr.apply(SPECIES.length());
2525         boolean[] mask = fm.apply(SPECIES.length());
2526         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2527 
2528         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2529             for (int i = 0; i < a.length; i += SPECIES.length()) {
2530                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2531                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2532                 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2533             }
2534         }
2535 
2536         assertArraysEquals(r, a, b, mask, Short256VectorTests::ROR);
2537     }
2538 

2539     static short ROL(short a, short b) {
2540         return (short)(ROL_scalar(a,b));
2541     }
2542 
2543     @Test(dataProvider = "shortBinaryOpProvider")
2544     static void ROLShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2545         short[] a = fa.apply(SPECIES.length());
2546         short[] b = fb.apply(SPECIES.length());
2547         short[] r = fr.apply(SPECIES.length());
2548 
2549         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2550             for (int i = 0; i < a.length; i += SPECIES.length()) {
2551                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2552                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2553                 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2554             }
2555         }
2556 
2557         assertArraysEquals(r, a, b, Short256VectorTests::ROL);
2558     }
2559 


2560     @Test(dataProvider = "shortBinaryOpMaskProvider")
2561     static void ROLShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2562                                           IntFunction<boolean[]> fm) {
2563         short[] a = fa.apply(SPECIES.length());
2564         short[] b = fb.apply(SPECIES.length());
2565         short[] r = fr.apply(SPECIES.length());
2566         boolean[] mask = fm.apply(SPECIES.length());
2567         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2568 
2569         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2570             for (int i = 0; i < a.length; i += SPECIES.length()) {
2571                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2572                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2573                 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2574             }
2575         }
2576 
2577         assertArraysEquals(r, a, b, mask, Short256VectorTests::ROL);
2578     }
2579 

2580     static short ROR_unary(short a, short b) {
2581         return (short)(ROR_scalar(a, b));
2582     }
2583 
2584     @Test(dataProvider = "shortBinaryOpProvider")
2585     static void RORShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2586         short[] a = fa.apply(SPECIES.length());
2587         short[] b = fb.apply(SPECIES.length());
2588         short[] r = fr.apply(SPECIES.length());
2589 
2590         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2591             for (int i = 0; i < a.length; i += SPECIES.length()) {
2592                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2593                 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2594             }
2595         }
2596 
2597         assertShiftArraysEquals(r, a, b, Short256VectorTests::ROR_unary);
2598     }
2599 


2600     @Test(dataProvider = "shortBinaryOpMaskProvider")
2601     static void RORShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2602                                           IntFunction<boolean[]> fm) {
2603         short[] a = fa.apply(SPECIES.length());
2604         short[] b = fb.apply(SPECIES.length());
2605         short[] r = fr.apply(SPECIES.length());
2606         boolean[] mask = fm.apply(SPECIES.length());
2607         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2608 
2609         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2610             for (int i = 0; i < a.length; i += SPECIES.length()) {
2611                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2612                 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2613             }
2614         }
2615 
2616         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ROR_unary);
2617     }
2618 

2619     static short ROL_unary(short a, short b) {
2620         return (short)(ROL_scalar(a, b));
2621     }
2622 
2623     @Test(dataProvider = "shortBinaryOpProvider")
2624     static void ROLShort256VectorTestsScalarShift(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2625         short[] a = fa.apply(SPECIES.length());
2626         short[] b = fb.apply(SPECIES.length());
2627         short[] r = fr.apply(SPECIES.length());
2628 
2629         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2630             for (int i = 0; i < a.length; i += SPECIES.length()) {
2631                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2632                 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2633             }
2634         }
2635 
2636         assertShiftArraysEquals(r, a, b, Short256VectorTests::ROL_unary);
2637     }
2638 


2639     @Test(dataProvider = "shortBinaryOpMaskProvider")
2640     static void ROLShort256VectorTestsScalarShiftMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
2641                                           IntFunction<boolean[]> fm) {
2642         short[] a = fa.apply(SPECIES.length());
2643         short[] b = fb.apply(SPECIES.length());
2644         short[] r = fr.apply(SPECIES.length());
2645         boolean[] mask = fm.apply(SPECIES.length());
2646         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2647 
2648         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2649             for (int i = 0; i < a.length; i += SPECIES.length()) {
2650                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2651                 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2652             }
2653         }
2654 
2655         assertShiftArraysEquals(r, a, b, mask, Short256VectorTests::ROL_unary);
2656     }






2657     static short LSHR_binary_const(short a) {
2658         return (short)(((a & 0xFFFF) >>> CONST_SHIFT));
2659     }
2660 
2661     @Test(dataProvider = "shortUnaryOpProvider")
2662     static void LSHRShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2663         short[] a = fa.apply(SPECIES.length());
2664         short[] r = fr.apply(SPECIES.length());
2665 
2666         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2667             for (int i = 0; i < a.length; i += SPECIES.length()) {
2668                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2669                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
2670             }
2671         }
2672 
2673         assertShiftConstEquals(r, a, Short256VectorTests::LSHR_binary_const);
2674     }
2675 


2676     @Test(dataProvider = "shortUnaryOpMaskProvider")
2677     static void LSHRShort256VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2678                                           IntFunction<boolean[]> fm) {
2679         short[] a = fa.apply(SPECIES.length());
2680         short[] r = fr.apply(SPECIES.length());
2681         boolean[] mask = fm.apply(SPECIES.length());
2682         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2683 
2684         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2685             for (int i = 0; i < a.length; i += SPECIES.length()) {
2686                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2687                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
2688             }
2689         }
2690 
2691         assertShiftConstEquals(r, a, mask, Short256VectorTests::LSHR_binary_const);
2692     }
2693 


2694     static short LSHL_binary_const(short a) {
2695         return (short)((a << CONST_SHIFT));
2696     }
2697 
2698     @Test(dataProvider = "shortUnaryOpProvider")
2699     static void LSHLShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2700         short[] a = fa.apply(SPECIES.length());
2701         short[] r = fr.apply(SPECIES.length());
2702 
2703         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2704             for (int i = 0; i < a.length; i += SPECIES.length()) {
2705                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2706                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
2707             }
2708         }
2709 
2710         assertShiftConstEquals(r, a, Short256VectorTests::LSHL_binary_const);
2711     }
2712 


2713     @Test(dataProvider = "shortUnaryOpMaskProvider")
2714     static void LSHLShort256VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2715                                           IntFunction<boolean[]> fm) {
2716         short[] a = fa.apply(SPECIES.length());
2717         short[] r = fr.apply(SPECIES.length());
2718         boolean[] mask = fm.apply(SPECIES.length());
2719         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2720 
2721         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2722             for (int i = 0; i < a.length; i += SPECIES.length()) {
2723                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2724                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
2725             }
2726         }
2727 
2728         assertShiftConstEquals(r, a, mask, Short256VectorTests::LSHL_binary_const);
2729     }
2730 


2731     static short ASHR_binary_const(short a) {
2732         return (short)((a >> CONST_SHIFT));
2733     }
2734 
2735     @Test(dataProvider = "shortUnaryOpProvider")
2736     static void ASHRShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2737         short[] a = fa.apply(SPECIES.length());
2738         short[] r = fr.apply(SPECIES.length());
2739 
2740         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2741             for (int i = 0; i < a.length; i += SPECIES.length()) {
2742                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2743                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
2744             }
2745         }
2746 
2747         assertShiftConstEquals(r, a, Short256VectorTests::ASHR_binary_const);
2748     }
2749 


2750     @Test(dataProvider = "shortUnaryOpMaskProvider")
2751     static void ASHRShort256VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2752                                           IntFunction<boolean[]> fm) {
2753         short[] a = fa.apply(SPECIES.length());
2754         short[] r = fr.apply(SPECIES.length());
2755         boolean[] mask = fm.apply(SPECIES.length());
2756         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2757 
2758         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2759             for (int i = 0; i < a.length; i += SPECIES.length()) {
2760                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2761                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
2762             }
2763         }
2764 
2765         assertShiftConstEquals(r, a, mask, Short256VectorTests::ASHR_binary_const);
2766     }
2767 


2768     static short ROR_binary_const(short a) {
2769         return (short)(ROR_scalar(a, CONST_SHIFT));
2770     }
2771 
2772     @Test(dataProvider = "shortUnaryOpProvider")
2773     static void RORShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2774         short[] a = fa.apply(SPECIES.length());
2775         short[] r = fr.apply(SPECIES.length());
2776 
2777         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2778             for (int i = 0; i < a.length; i += SPECIES.length()) {
2779                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2780                 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
2781             }
2782         }
2783 
2784         assertShiftConstEquals(r, a, Short256VectorTests::ROR_binary_const);
2785     }
2786 


2787     @Test(dataProvider = "shortUnaryOpMaskProvider")
2788     static void RORShort256VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2789                                           IntFunction<boolean[]> fm) {
2790         short[] a = fa.apply(SPECIES.length());
2791         short[] r = fr.apply(SPECIES.length());
2792         boolean[] mask = fm.apply(SPECIES.length());
2793         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2794 
2795         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2796             for (int i = 0; i < a.length; i += SPECIES.length()) {
2797                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2798                 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
2799             }
2800         }
2801 
2802         assertShiftConstEquals(r, a, mask, Short256VectorTests::ROR_binary_const);
2803     }
2804 


2805     static short ROL_binary_const(short a) {
2806         return (short)(ROL_scalar(a, CONST_SHIFT));
2807     }
2808 
2809     @Test(dataProvider = "shortUnaryOpProvider")
2810     static void ROLShort256VectorTestsScalarShiftConst(IntFunction<short[]> fa) {
2811         short[] a = fa.apply(SPECIES.length());
2812         short[] r = fr.apply(SPECIES.length());
2813 
2814         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2815             for (int i = 0; i < a.length; i += SPECIES.length()) {
2816                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2817                 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
2818             }
2819         }
2820 
2821         assertShiftConstEquals(r, a, Short256VectorTests::ROL_binary_const);
2822     }
2823 


2824     @Test(dataProvider = "shortUnaryOpMaskProvider")
2825     static void ROLShort256VectorTestsScalarShiftMaskedConst(IntFunction<short[]> fa,
2826                                           IntFunction<boolean[]> fm) {
2827         short[] a = fa.apply(SPECIES.length());
2828         short[] r = fr.apply(SPECIES.length());
2829         boolean[] mask = fm.apply(SPECIES.length());
2830         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2831 
2832         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2833             for (int i = 0; i < a.length; i += SPECIES.length()) {
2834                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2835                 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
2836             }
2837         }
2838 
2839         assertShiftConstEquals(r, a, mask, Short256VectorTests::ROL_binary_const);
2840     }
2841 
2842 
2843     static short MIN(short a, short b) {
2844         return (short)(Math.min(a, b));
2845     }
2846 
2847     @Test(dataProvider = "shortBinaryOpProvider")
2848     static void MINShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2849         short[] a = fa.apply(SPECIES.length());
2850         short[] b = fb.apply(SPECIES.length());
2851         short[] r = fr.apply(SPECIES.length());
2852 
2853         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2854             for (int i = 0; i < a.length; i += SPECIES.length()) {
2855                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2856                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2857                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2858             }
2859         }
2860 
2861         assertArraysEquals(r, a, b, Short256VectorTests::MIN);
2862     }
2863 
2864     static short min(short a, short b) {
2865         return (short)(Math.min(a, b));
2866     }
2867 
2868     @Test(dataProvider = "shortBinaryOpProvider")
2869     static void minShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2870         short[] a = fa.apply(SPECIES.length());
2871         short[] b = fb.apply(SPECIES.length());
2872         short[] r = fr.apply(SPECIES.length());
2873 
2874         for (int i = 0; i < a.length; i += SPECIES.length()) {
2875             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2876             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2877             av.min(bv).intoArray(r, i);
2878         }
2879 
2880         assertArraysEquals(r, a, b, Short256VectorTests::min);
2881     }
2882 
2883     static short MAX(short a, short b) {
2884         return (short)(Math.max(a, b));
2885     }
2886 
2887     @Test(dataProvider = "shortBinaryOpProvider")
2888     static void MAXShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2889         short[] a = fa.apply(SPECIES.length());
2890         short[] b = fb.apply(SPECIES.length());
2891         short[] r = fr.apply(SPECIES.length());
2892 
2893         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2894             for (int i = 0; i < a.length; i += SPECIES.length()) {
2895                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2896                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2897                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2898             }
2899         }
2900 
2901         assertArraysEquals(r, a, b, Short256VectorTests::MAX);
2902     }
2903 
2904     static short max(short a, short b) {
2905         return (short)(Math.max(a, b));
2906     }
2907 
2908     @Test(dataProvider = "shortBinaryOpProvider")
2909     static void maxShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
2910         short[] a = fa.apply(SPECIES.length());
2911         short[] b = fb.apply(SPECIES.length());
2912         short[] r = fr.apply(SPECIES.length());
2913 
2914         for (int i = 0; i < a.length; i += SPECIES.length()) {
2915             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
2916             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
2917             av.max(bv).intoArray(r, i);
2918         }
2919 
2920         assertArraysEquals(r, a, b, Short256VectorTests::max);
2921     }
2922 
2923     @Test(dataProvider = "shortBinaryOpProvider")

2977     }
2978 
2979     static short ANDReduce(short[] a, int idx) {
2980         short res = -1;
2981         for (int i = idx; i < (idx + SPECIES.length()); i++) {
2982             res &= a[i];
2983         }
2984 
2985         return res;
2986     }
2987 
2988     static short ANDReduceAll(short[] a) {
2989         short res = -1;
2990         for (int i = 0; i < a.length; i += SPECIES.length()) {
2991             res &= ANDReduce(a, i);
2992         }
2993 
2994         return res;
2995     }
2996 

2997     @Test(dataProvider = "shortUnaryOpProvider")
2998     static void ANDReduceShort256VectorTests(IntFunction<short[]> fa) {
2999         short[] a = fa.apply(SPECIES.length());
3000         short[] r = fr.apply(SPECIES.length());
3001         short ra = -1;
3002 
3003         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3004             for (int i = 0; i < a.length; i += SPECIES.length()) {
3005                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3006                 r[i] = av.reduceLanes(VectorOperators.AND);
3007             }
3008         }
3009 
3010         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3011             ra = -1;
3012             for (int i = 0; i < a.length; i += SPECIES.length()) {
3013                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3014                 ra &= av.reduceLanes(VectorOperators.AND);
3015             }
3016         }
3017 
3018         assertReductionArraysEquals(r, ra, a,
3019                 Short256VectorTests::ANDReduce, Short256VectorTests::ANDReduceAll);
3020     }
3021 

3022     static short ANDReduceMasked(short[] a, int idx, boolean[] mask) {
3023         short res = -1;
3024         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3025             if (mask[i % SPECIES.length()])
3026                 res &= a[i];
3027         }
3028 
3029         return res;
3030     }
3031 
3032     static short ANDReduceAllMasked(short[] a, boolean[] mask) {
3033         short res = -1;
3034         for (int i = 0; i < a.length; i += SPECIES.length()) {
3035             res &= ANDReduceMasked(a, i, mask);
3036         }
3037 
3038         return res;
3039     }
3040 

3041     @Test(dataProvider = "shortUnaryOpMaskProvider")
3042     static void ANDReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3043         short[] a = fa.apply(SPECIES.length());
3044         short[] r = fr.apply(SPECIES.length());
3045         boolean[] mask = fm.apply(SPECIES.length());
3046         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3047         short ra = -1;
3048 
3049         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3050             for (int i = 0; i < a.length; i += SPECIES.length()) {
3051                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3052                 r[i] = av.reduceLanes(VectorOperators.AND, vmask);
3053             }
3054         }
3055 
3056         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3057             ra = -1;
3058             for (int i = 0; i < a.length; i += SPECIES.length()) {
3059                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3060                 ra &= av.reduceLanes(VectorOperators.AND, vmask);
3061             }
3062         }
3063 
3064         assertReductionArraysEqualsMasked(r, ra, a, mask,
3065                 Short256VectorTests::ANDReduceMasked, Short256VectorTests::ANDReduceAllMasked);
3066     }
3067 

3068     static short ORReduce(short[] a, int idx) {
3069         short res = 0;
3070         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3071             res |= a[i];
3072         }
3073 
3074         return res;
3075     }
3076 
3077     static short ORReduceAll(short[] a) {
3078         short res = 0;
3079         for (int i = 0; i < a.length; i += SPECIES.length()) {
3080             res |= ORReduce(a, i);
3081         }
3082 
3083         return res;
3084     }
3085 

3086     @Test(dataProvider = "shortUnaryOpProvider")
3087     static void ORReduceShort256VectorTests(IntFunction<short[]> fa) {
3088         short[] a = fa.apply(SPECIES.length());
3089         short[] r = fr.apply(SPECIES.length());
3090         short ra = 0;
3091 
3092         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3093             for (int i = 0; i < a.length; i += SPECIES.length()) {
3094                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3095                 r[i] = av.reduceLanes(VectorOperators.OR);
3096             }
3097         }
3098 
3099         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3100             ra = 0;
3101             for (int i = 0; i < a.length; i += SPECIES.length()) {
3102                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3103                 ra |= av.reduceLanes(VectorOperators.OR);
3104             }
3105         }
3106 
3107         assertReductionArraysEquals(r, ra, a,
3108                 Short256VectorTests::ORReduce, Short256VectorTests::ORReduceAll);
3109     }
3110 

3111     static short ORReduceMasked(short[] a, int idx, boolean[] mask) {
3112         short res = 0;
3113         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3114             if (mask[i % SPECIES.length()])
3115                 res |= a[i];
3116         }
3117 
3118         return res;
3119     }
3120 
3121     static short ORReduceAllMasked(short[] a, boolean[] mask) {
3122         short res = 0;
3123         for (int i = 0; i < a.length; i += SPECIES.length()) {
3124             res |= ORReduceMasked(a, i, mask);
3125         }
3126 
3127         return res;
3128     }
3129 

3130     @Test(dataProvider = "shortUnaryOpMaskProvider")
3131     static void ORReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3132         short[] a = fa.apply(SPECIES.length());
3133         short[] r = fr.apply(SPECIES.length());
3134         boolean[] mask = fm.apply(SPECIES.length());
3135         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3136         short ra = 0;
3137 
3138         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3139             for (int i = 0; i < a.length; i += SPECIES.length()) {
3140                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3141                 r[i] = av.reduceLanes(VectorOperators.OR, vmask);
3142             }
3143         }
3144 
3145         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3146             ra = 0;
3147             for (int i = 0; i < a.length; i += SPECIES.length()) {
3148                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3149                 ra |= av.reduceLanes(VectorOperators.OR, vmask);
3150             }
3151         }
3152 
3153         assertReductionArraysEqualsMasked(r, ra, a, mask,
3154                 Short256VectorTests::ORReduceMasked, Short256VectorTests::ORReduceAllMasked);
3155     }
3156 

3157     static short XORReduce(short[] a, int idx) {
3158         short res = 0;
3159         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3160             res ^= a[i];
3161         }
3162 
3163         return res;
3164     }
3165 
3166     static short XORReduceAll(short[] a) {
3167         short res = 0;
3168         for (int i = 0; i < a.length; i += SPECIES.length()) {
3169             res ^= XORReduce(a, i);
3170         }
3171 
3172         return res;
3173     }
3174 

3175     @Test(dataProvider = "shortUnaryOpProvider")
3176     static void XORReduceShort256VectorTests(IntFunction<short[]> fa) {
3177         short[] a = fa.apply(SPECIES.length());
3178         short[] r = fr.apply(SPECIES.length());
3179         short ra = 0;
3180 
3181         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3182             for (int i = 0; i < a.length; i += SPECIES.length()) {
3183                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3184                 r[i] = av.reduceLanes(VectorOperators.XOR);
3185             }
3186         }
3187 
3188         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3189             ra = 0;
3190             for (int i = 0; i < a.length; i += SPECIES.length()) {
3191                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3192                 ra ^= av.reduceLanes(VectorOperators.XOR);
3193             }
3194         }
3195 
3196         assertReductionArraysEquals(r, ra, a,
3197                 Short256VectorTests::XORReduce, Short256VectorTests::XORReduceAll);
3198     }
3199 

3200     static short XORReduceMasked(short[] a, int idx, boolean[] mask) {
3201         short res = 0;
3202         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3203             if (mask[i % SPECIES.length()])
3204                 res ^= a[i];
3205         }
3206 
3207         return res;
3208     }
3209 
3210     static short XORReduceAllMasked(short[] a, boolean[] mask) {
3211         short res = 0;
3212         for (int i = 0; i < a.length; i += SPECIES.length()) {
3213             res ^= XORReduceMasked(a, i, mask);
3214         }
3215 
3216         return res;
3217     }
3218 

3219     @Test(dataProvider = "shortUnaryOpMaskProvider")
3220     static void XORReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3221         short[] a = fa.apply(SPECIES.length());
3222         short[] r = fr.apply(SPECIES.length());
3223         boolean[] mask = fm.apply(SPECIES.length());
3224         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3225         short ra = 0;
3226 
3227         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3228             for (int i = 0; i < a.length; i += SPECIES.length()) {
3229                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3230                 r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
3231             }
3232         }
3233 
3234         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3235             ra = 0;
3236             for (int i = 0; i < a.length; i += SPECIES.length()) {
3237                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3238                 ra ^= av.reduceLanes(VectorOperators.XOR, vmask);

3243                 Short256VectorTests::XORReduceMasked, Short256VectorTests::XORReduceAllMasked);
3244     }
3245 
3246     static short ADDReduce(short[] a, int idx) {
3247         short res = 0;
3248         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3249             res += a[i];
3250         }
3251 
3252         return res;
3253     }
3254 
3255     static short ADDReduceAll(short[] a) {
3256         short res = 0;
3257         for (int i = 0; i < a.length; i += SPECIES.length()) {
3258             res += ADDReduce(a, i);
3259         }
3260 
3261         return res;
3262     }
3263 
3264     @Test(dataProvider = "shortUnaryOpProvider")
3265     static void ADDReduceShort256VectorTests(IntFunction<short[]> fa) {
3266         short[] a = fa.apply(SPECIES.length());
3267         short[] r = fr.apply(SPECIES.length());
3268         short ra = 0;
3269 
3270         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3271             for (int i = 0; i < a.length; i += SPECIES.length()) {
3272                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3273                 r[i] = av.reduceLanes(VectorOperators.ADD);
3274             }
3275         }
3276 
3277         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3278             ra = 0;
3279             for (int i = 0; i < a.length; i += SPECIES.length()) {
3280                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3281                 ra += av.reduceLanes(VectorOperators.ADD);
3282             }
3283         }
3284 
3285         assertReductionArraysEquals(r, ra, a,
3286                 Short256VectorTests::ADDReduce, Short256VectorTests::ADDReduceAll);
3287     }
3288 
3289     static short ADDReduceMasked(short[] a, int idx, boolean[] mask) {
3290         short res = 0;
3291         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3292             if (mask[i % SPECIES.length()])
3293                 res += a[i];
3294         }
3295 
3296         return res;
3297     }
3298 
3299     static short ADDReduceAllMasked(short[] a, boolean[] mask) {
3300         short res = 0;
3301         for (int i = 0; i < a.length; i += SPECIES.length()) {
3302             res += ADDReduceMasked(a, i, mask);
3303         }
3304 
3305         return res;
3306     }
3307 
3308     @Test(dataProvider = "shortUnaryOpMaskProvider")
3309     static void ADDReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3310         short[] a = fa.apply(SPECIES.length());
3311         short[] r = fr.apply(SPECIES.length());
3312         boolean[] mask = fm.apply(SPECIES.length());
3313         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3314         short ra = 0;
3315 
3316         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3317             for (int i = 0; i < a.length; i += SPECIES.length()) {
3318                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3319                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3320             }
3321         }
3322 
3323         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3324             ra = 0;
3325             for (int i = 0; i < a.length; i += SPECIES.length()) {
3326                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3327                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3328             }
3329         }
3330 
3331         assertReductionArraysEqualsMasked(r, ra, a, mask,
3332                 Short256VectorTests::ADDReduceMasked, Short256VectorTests::ADDReduceAllMasked);
3333     }
3334 
3335     static short MULReduce(short[] a, int idx) {
3336         short res = 1;
3337         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3338             res *= a[i];
3339         }
3340 
3341         return res;
3342     }
3343 
3344     static short MULReduceAll(short[] a) {
3345         short res = 1;
3346         for (int i = 0; i < a.length; i += SPECIES.length()) {
3347             res *= MULReduce(a, i);
3348         }
3349 
3350         return res;
3351     }
3352 
3353     @Test(dataProvider = "shortUnaryOpProvider")
3354     static void MULReduceShort256VectorTests(IntFunction<short[]> fa) {
3355         short[] a = fa.apply(SPECIES.length());
3356         short[] r = fr.apply(SPECIES.length());
3357         short ra = 1;
3358 
3359         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3360             for (int i = 0; i < a.length; i += SPECIES.length()) {
3361                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3362                 r[i] = av.reduceLanes(VectorOperators.MUL);
3363             }
3364         }
3365 
3366         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3367             ra = 1;
3368             for (int i = 0; i < a.length; i += SPECIES.length()) {
3369                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3370                 ra *= av.reduceLanes(VectorOperators.MUL);
3371             }
3372         }
3373 
3374         assertReductionArraysEquals(r, ra, a,
3375                 Short256VectorTests::MULReduce, Short256VectorTests::MULReduceAll);
3376     }
3377 
3378     static short MULReduceMasked(short[] a, int idx, boolean[] mask) {
3379         short res = 1;
3380         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3381             if (mask[i % SPECIES.length()])
3382                 res *= a[i];
3383         }
3384 
3385         return res;
3386     }
3387 
3388     static short MULReduceAllMasked(short[] a, boolean[] mask) {
3389         short res = 1;
3390         for (int i = 0; i < a.length; i += SPECIES.length()) {
3391             res *= MULReduceMasked(a, i, mask);
3392         }
3393 
3394         return res;
3395     }
3396 
3397     @Test(dataProvider = "shortUnaryOpMaskProvider")
3398     static void MULReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3399         short[] a = fa.apply(SPECIES.length());
3400         short[] r = fr.apply(SPECIES.length());
3401         boolean[] mask = fm.apply(SPECIES.length());
3402         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3403         short ra = 1;
3404 
3405         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3406             for (int i = 0; i < a.length; i += SPECIES.length()) {
3407                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3408                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3409             }
3410         }
3411 
3412         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3413             ra = 1;
3414             for (int i = 0; i < a.length; i += SPECIES.length()) {
3415                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3416                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
3417             }
3418         }
3419 
3420         assertReductionArraysEqualsMasked(r, ra, a, mask,
3421                 Short256VectorTests::MULReduceMasked, Short256VectorTests::MULReduceAllMasked);
3422     }
3423 
3424     static short MINReduce(short[] a, int idx) {
3425         short res = Short.MAX_VALUE;
3426         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3427             res = (short) Math.min(res, a[i]);
3428         }
3429 
3430         return res;
3431     }
3432 
3433     static short MINReduceAll(short[] a) {
3434         short res = Short.MAX_VALUE;
3435         for (int i = 0; i < a.length; i += SPECIES.length()) {
3436             res = (short) Math.min(res, MINReduce(a, i));
3437         }
3438 
3439         return res;
3440     }
3441 
3442     @Test(dataProvider = "shortUnaryOpProvider")
3443     static void MINReduceShort256VectorTests(IntFunction<short[]> fa) {
3444         short[] a = fa.apply(SPECIES.length());
3445         short[] r = fr.apply(SPECIES.length());
3446         short ra = Short.MAX_VALUE;
3447 
3448         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3449             for (int i = 0; i < a.length; i += SPECIES.length()) {
3450                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3451                 r[i] = av.reduceLanes(VectorOperators.MIN);
3452             }
3453         }
3454 
3455         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3456             ra = Short.MAX_VALUE;
3457             for (int i = 0; i < a.length; i += SPECIES.length()) {
3458                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3459                 ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
3460             }
3461         }
3462 
3463         assertReductionArraysEquals(r, ra, a,
3464                 Short256VectorTests::MINReduce, Short256VectorTests::MINReduceAll);
3465     }
3466 
3467     static short MINReduceMasked(short[] a, int idx, boolean[] mask) {
3468         short res = Short.MAX_VALUE;
3469         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3470             if (mask[i % SPECIES.length()])
3471                 res = (short) Math.min(res, a[i]);
3472         }
3473 
3474         return res;
3475     }
3476 
3477     static short MINReduceAllMasked(short[] a, boolean[] mask) {
3478         short res = Short.MAX_VALUE;
3479         for (int i = 0; i < a.length; i += SPECIES.length()) {
3480             res = (short) Math.min(res, MINReduceMasked(a, i, mask));
3481         }
3482 
3483         return res;
3484     }
3485 
3486     @Test(dataProvider = "shortUnaryOpMaskProvider")
3487     static void MINReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3488         short[] a = fa.apply(SPECIES.length());
3489         short[] r = fr.apply(SPECIES.length());
3490         boolean[] mask = fm.apply(SPECIES.length());
3491         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3492         short ra = Short.MAX_VALUE;
3493 
3494         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3495             for (int i = 0; i < a.length; i += SPECIES.length()) {
3496                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3497                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
3498             }
3499         }
3500 
3501         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3502             ra = Short.MAX_VALUE;
3503             for (int i = 0; i < a.length; i += SPECIES.length()) {
3504                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3505                 ra = (short) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
3506             }
3507         }
3508 
3509         assertReductionArraysEqualsMasked(r, ra, a, mask,
3510                 Short256VectorTests::MINReduceMasked, Short256VectorTests::MINReduceAllMasked);
3511     }
3512 
3513     static short MAXReduce(short[] a, int idx) {
3514         short res = Short.MIN_VALUE;
3515         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3516             res = (short) Math.max(res, a[i]);
3517         }
3518 
3519         return res;
3520     }
3521 
3522     static short MAXReduceAll(short[] a) {
3523         short res = Short.MIN_VALUE;
3524         for (int i = 0; i < a.length; i += SPECIES.length()) {
3525             res = (short) Math.max(res, MAXReduce(a, i));
3526         }
3527 
3528         return res;
3529     }
3530 
3531     @Test(dataProvider = "shortUnaryOpProvider")
3532     static void MAXReduceShort256VectorTests(IntFunction<short[]> fa) {
3533         short[] a = fa.apply(SPECIES.length());
3534         short[] r = fr.apply(SPECIES.length());
3535         short ra = Short.MIN_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.MAX);
3541             }
3542         }
3543 
3544         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3545             ra = Short.MIN_VALUE;
3546             for (int i = 0; i < a.length; i += SPECIES.length()) {
3547                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3548                 ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
3549             }
3550         }
3551 
3552         assertReductionArraysEquals(r, ra, a,
3553                 Short256VectorTests::MAXReduce, Short256VectorTests::MAXReduceAll);
3554     }
3555 
3556     static short MAXReduceMasked(short[] a, int idx, boolean[] mask) {
3557         short res = Short.MIN_VALUE;
3558         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3559             if (mask[i % SPECIES.length()])
3560                 res = (short) Math.max(res, a[i]);
3561         }
3562 
3563         return res;
3564     }
3565 
3566     static short MAXReduceAllMasked(short[] a, boolean[] mask) {
3567         short res = Short.MIN_VALUE;
3568         for (int i = 0; i < a.length; i += SPECIES.length()) {
3569             res = (short) Math.max(res, MAXReduceMasked(a, i, mask));
3570         }
3571 
3572         return res;
3573     }
3574 
3575     @Test(dataProvider = "shortUnaryOpMaskProvider")
3576     static void MAXReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3577         short[] a = fa.apply(SPECIES.length());
3578         short[] r = fr.apply(SPECIES.length());
3579         boolean[] mask = fm.apply(SPECIES.length());
3580         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3581         short ra = Short.MIN_VALUE;
3582 
3583         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3584             for (int i = 0; i < a.length; i += SPECIES.length()) {
3585                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3586                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
3587             }
3588         }
3589 
3590         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3591             ra = Short.MIN_VALUE;
3592             for (int i = 0; i < a.length; i += SPECIES.length()) {
3593                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3594                 ra = (short) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
3595             }
3596         }
3597 
3598         assertReductionArraysEqualsMasked(r, ra, a, mask,
3599                 Short256VectorTests::MAXReduceMasked, Short256VectorTests::MAXReduceAllMasked);
3600     }
3601 
3602     static short FIRST_NONZEROReduce(short[] a, int idx) {
3603         short res = (short) 0;
3604         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3605             res = firstNonZero(res, a[i]);
3606         }
3607 
3608         return res;
3609     }
3610 
3611     static short FIRST_NONZEROReduceAll(short[] a) {
3612         short res = (short) 0;
3613         for (int i = 0; i < a.length; i += SPECIES.length()) {
3614             res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
3615         }
3616 
3617         return res;
3618     }
3619 
3620     @Test(dataProvider = "shortUnaryOpProvider")
3621     static void FIRST_NONZEROReduceShort256VectorTests(IntFunction<short[]> fa) {
3622         short[] a = fa.apply(SPECIES.length());
3623         short[] r = fr.apply(SPECIES.length());
3624         short ra = (short) 0;
3625 
3626         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3627             for (int i = 0; i < a.length; i += SPECIES.length()) {
3628                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3629                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
3630             }
3631         }
3632 
3633         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3634             ra = (short) 0;
3635             for (int i = 0; i < a.length; i += SPECIES.length()) {
3636                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3637                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
3638             }
3639         }
3640 
3641         assertReductionArraysEquals(r, ra, a,
3642                 Short256VectorTests::FIRST_NONZEROReduce, Short256VectorTests::FIRST_NONZEROReduceAll);
3643     }
3644 
3645     static short FIRST_NONZEROReduceMasked(short[] a, int idx, boolean[] mask) {
3646         short res = (short) 0;
3647         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3648             if (mask[i % SPECIES.length()])
3649                 res = firstNonZero(res, a[i]);
3650         }
3651 
3652         return res;
3653     }
3654 
3655     static short FIRST_NONZEROReduceAllMasked(short[] a, boolean[] mask) {
3656         short res = (short) 0;
3657         for (int i = 0; i < a.length; i += SPECIES.length()) {
3658             res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
3659         }
3660 
3661         return res;
3662     }
3663 
3664     @Test(dataProvider = "shortUnaryOpMaskProvider")
3665     static void FIRST_NONZEROReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
3666         short[] a = fa.apply(SPECIES.length());
3667         short[] r = fr.apply(SPECIES.length());
3668         boolean[] mask = fm.apply(SPECIES.length());
3669         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3670         short ra = (short) 0;
3671 
3672         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3673             for (int i = 0; i < a.length; i += SPECIES.length()) {
3674                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3675                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
3676             }
3677         }
3678 
3679         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3680             ra = (short) 0;
3681             for (int i = 0; i < a.length; i += SPECIES.length()) {
3682                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3683                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
3684             }
3685         }
3686 
3687         assertReductionArraysEqualsMasked(r, ra, a, mask,
3688                 Short256VectorTests::FIRST_NONZEROReduceMasked, Short256VectorTests::FIRST_NONZEROReduceAllMasked);
3689     }
3690 
3691     static boolean anyTrue(boolean[] a, int idx) {
3692         boolean res = false;
3693         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3694             res |= a[i];
3695         }
3696 
3697         return res;
3698     }
3699 

3700     @Test(dataProvider = "boolUnaryOpProvider")
3701     static void anyTrueShort256VectorTests(IntFunction<boolean[]> fm) {
3702         boolean[] mask = fm.apply(SPECIES.length());
3703         boolean[] r = fmr.apply(SPECIES.length());
3704 
3705         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3706             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3707                 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);
3708                 r[i] = vmask.anyTrue();
3709             }
3710         }
3711 
3712         assertReductionBoolArraysEquals(r, mask, Short256VectorTests::anyTrue);
3713     }
3714 

3715     static boolean allTrue(boolean[] a, int idx) {
3716         boolean res = true;
3717         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3718             res &= a[i];
3719         }
3720 
3721         return res;
3722     }
3723 

3724     @Test(dataProvider = "boolUnaryOpProvider")
3725     static void allTrueShort256VectorTests(IntFunction<boolean[]> fm) {
3726         boolean[] mask = fm.apply(SPECIES.length());
3727         boolean[] r = fmr.apply(SPECIES.length());
3728 
3729         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3730             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3731                 VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, i);
3732                 r[i] = vmask.allTrue();
3733             }
3734         }
3735 
3736         assertReductionBoolArraysEquals(r, mask, Short256VectorTests::allTrue);
3737     }
3738 

3739     @Test(dataProvider = "shortUnaryOpProvider")
3740     static void withShort256VectorTests(IntFunction<short []> fa) {
3741         short[] a = fa.apply(SPECIES.length());
3742         short[] r = fr.apply(SPECIES.length());
3743 
3744         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3745             for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3746                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3747                 av.withLane((j++ & (SPECIES.length()-1)), (short)(65535+i)).intoArray(r, i);
3748             }
3749         }
3750 
3751 
3752         for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3753             assertInsertArraysEquals(r, a, (short)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
3754         }
3755     }
3756 
3757     static boolean testIS_DEFAULT(short a) {
3758         return bits(a)==0;
3759     }
3760 
3761     @Test(dataProvider = "shortTestOpProvider")
3762     static void IS_DEFAULTShort256VectorTests(IntFunction<short[]> fa) {
3763         short[] a = fa.apply(SPECIES.length());
3764 
3765         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3766             for (int i = 0; i < a.length; i += SPECIES.length()) {
3767                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3768                 VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT);
3769 
3770                 // Check results as part of computation.
3771                 for (int j = 0; j < SPECIES.length(); j++) {
3772                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3773                 }
3774             }
3775         }
3776     }
3777 
3778     @Test(dataProvider = "shortTestOpMaskProvider")
3779     static void IS_DEFAULTMaskedShort256VectorTests(IntFunction<short[]> fa,
3780                                           IntFunction<boolean[]> fm) {
3781         short[] a = fa.apply(SPECIES.length());
3782         boolean[] mask = fm.apply(SPECIES.length());
3783         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3784 
3785         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3786             for (int i = 0; i < a.length; i += SPECIES.length()) {
3787                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3788                 VectorMask<Short> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3789 
3790                 // Check results as part of computation.
3791                 for (int j = 0; j < SPECIES.length(); j++) {
3792                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3793                 }
3794             }
3795         }
3796     }
3797 
3798     static boolean testIS_NEGATIVE(short a) {
3799         return bits(a)<0;
3800     }
3801 
3802     @Test(dataProvider = "shortTestOpProvider")
3803     static void IS_NEGATIVEShort256VectorTests(IntFunction<short[]> fa) {
3804         short[] a = fa.apply(SPECIES.length());
3805 
3806         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3807             for (int i = 0; i < a.length; i += SPECIES.length()) {
3808                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3809                 VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE);
3810 
3811                 // Check results as part of computation.
3812                 for (int j = 0; j < SPECIES.length(); j++) {
3813                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3814                 }
3815             }
3816         }
3817     }

3819     @Test(dataProvider = "shortTestOpMaskProvider")
3820     static void IS_NEGATIVEMaskedShort256VectorTests(IntFunction<short[]> fa,
3821                                           IntFunction<boolean[]> fm) {
3822         short[] a = fa.apply(SPECIES.length());
3823         boolean[] mask = fm.apply(SPECIES.length());
3824         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3825 
3826         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3827             for (int i = 0; i < a.length; i += SPECIES.length()) {
3828                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3829                 VectorMask<Short> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3830 
3831                 // Check results as part of computation.
3832                 for (int j = 0; j < SPECIES.length(); j++) {
3833                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3834                 }
3835             }
3836         }
3837     }
3838 



3839     @Test(dataProvider = "shortCompareOpProvider")
3840     static void LTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3841         short[] a = fa.apply(SPECIES.length());
3842         short[] b = fb.apply(SPECIES.length());
3843 
3844         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3845             for (int i = 0; i < a.length; i += SPECIES.length()) {
3846                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3847                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3848                 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv);
3849 
3850                 // Check results as part of computation.
3851                 for (int j = 0; j < SPECIES.length(); j++) {
3852                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3853                 }
3854             }
3855         }
3856     }
3857 

3858     @Test(dataProvider = "shortCompareOpProvider")
3859     static void ltShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3860         short[] a = fa.apply(SPECIES.length());
3861         short[] b = fb.apply(SPECIES.length());
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                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3867                 VectorMask<Short> mv = av.lt(bv);
3868 
3869                 // Check results as part of computation.
3870                 for (int j = 0; j < SPECIES.length(); j++) {
3871                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3872                 }
3873             }
3874         }
3875     }
3876 
3877     @Test(dataProvider = "shortCompareOpMaskProvider")

3880         short[] a = fa.apply(SPECIES.length());
3881         short[] b = fb.apply(SPECIES.length());
3882         boolean[] mask = fm.apply(SPECIES.length());
3883 
3884         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3885 
3886         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3887             for (int i = 0; i < a.length; i += SPECIES.length()) {
3888                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3889                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3890                 VectorMask<Short> mv = av.compare(VectorOperators.LT, bv, vmask);
3891 
3892                 // Check results as part of computation.
3893                 for (int j = 0; j < SPECIES.length(); j++) {
3894                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3895                 }
3896             }
3897         }
3898     }
3899 

3900     @Test(dataProvider = "shortCompareOpProvider")
3901     static void GTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3902         short[] a = fa.apply(SPECIES.length());
3903         short[] b = fb.apply(SPECIES.length());
3904 
3905         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3906             for (int i = 0; i < a.length; i += SPECIES.length()) {
3907                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3908                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3909                 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv);
3910 
3911                 // Check results as part of computation.
3912                 for (int j = 0; j < SPECIES.length(); j++) {
3913                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3914                 }
3915             }
3916         }
3917     }
3918 
3919     @Test(dataProvider = "shortCompareOpMaskProvider")

3922         short[] a = fa.apply(SPECIES.length());
3923         short[] b = fb.apply(SPECIES.length());
3924         boolean[] mask = fm.apply(SPECIES.length());
3925 
3926         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3927 
3928         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3929             for (int i = 0; i < a.length; i += SPECIES.length()) {
3930                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3931                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3932                 VectorMask<Short> mv = av.compare(VectorOperators.GT, bv, vmask);
3933 
3934                 // Check results as part of computation.
3935                 for (int j = 0; j < SPECIES.length(); j++) {
3936                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
3937                 }
3938             }
3939         }
3940     }
3941 

3942     @Test(dataProvider = "shortCompareOpProvider")
3943     static void EQShort256VectorTests(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.EQ, bv);
3952 
3953                 // Check results as part of computation.
3954                 for (int j = 0; j < SPECIES.length(); j++) {
3955                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3956                 }
3957             }
3958         }
3959     }
3960 

3961     @Test(dataProvider = "shortCompareOpProvider")
3962     static void eqShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
3963         short[] a = fa.apply(SPECIES.length());
3964         short[] b = fb.apply(SPECIES.length());
3965 
3966         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3967             for (int i = 0; i < a.length; i += SPECIES.length()) {
3968                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3969                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3970                 VectorMask<Short> mv = av.eq(bv);
3971 
3972                 // Check results as part of computation.
3973                 for (int j = 0; j < SPECIES.length(); j++) {
3974                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3975                 }
3976             }
3977         }
3978     }
3979 
3980     @Test(dataProvider = "shortCompareOpMaskProvider")

3983         short[] a = fa.apply(SPECIES.length());
3984         short[] b = fb.apply(SPECIES.length());
3985         boolean[] mask = fm.apply(SPECIES.length());
3986 
3987         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3988 
3989         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3990             for (int i = 0; i < a.length; i += SPECIES.length()) {
3991                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
3992                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
3993                 VectorMask<Short> mv = av.compare(VectorOperators.EQ, bv, vmask);
3994 
3995                 // Check results as part of computation.
3996                 for (int j = 0; j < SPECIES.length(); j++) {
3997                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
3998                 }
3999             }
4000         }
4001     }
4002 

4003     @Test(dataProvider = "shortCompareOpProvider")
4004     static void NEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4005         short[] a = fa.apply(SPECIES.length());
4006         short[] b = fb.apply(SPECIES.length());
4007 
4008         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4009             for (int i = 0; i < a.length; i += SPECIES.length()) {
4010                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4011                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4012                 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv);
4013 
4014                 // Check results as part of computation.
4015                 for (int j = 0; j < SPECIES.length(); j++) {
4016                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
4017                 }
4018             }
4019         }
4020     }
4021 
4022     @Test(dataProvider = "shortCompareOpMaskProvider")

4025         short[] a = fa.apply(SPECIES.length());
4026         short[] b = fb.apply(SPECIES.length());
4027         boolean[] mask = fm.apply(SPECIES.length());
4028 
4029         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4030 
4031         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4032             for (int i = 0; i < a.length; i += SPECIES.length()) {
4033                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4034                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4035                 VectorMask<Short> mv = av.compare(VectorOperators.NE, bv, vmask);
4036 
4037                 // Check results as part of computation.
4038                 for (int j = 0; j < SPECIES.length(); j++) {
4039                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
4040                 }
4041             }
4042         }
4043     }
4044 

4045     @Test(dataProvider = "shortCompareOpProvider")
4046     static void LEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4047         short[] a = fa.apply(SPECIES.length());
4048         short[] b = fb.apply(SPECIES.length());
4049 
4050         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4051             for (int i = 0; i < a.length; i += SPECIES.length()) {
4052                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4053                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4054                 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv);
4055 
4056                 // Check results as part of computation.
4057                 for (int j = 0; j < SPECIES.length(); j++) {
4058                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
4059                 }
4060             }
4061         }
4062     }
4063 
4064     @Test(dataProvider = "shortCompareOpMaskProvider")

4067         short[] a = fa.apply(SPECIES.length());
4068         short[] b = fb.apply(SPECIES.length());
4069         boolean[] mask = fm.apply(SPECIES.length());
4070 
4071         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4072 
4073         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4074             for (int i = 0; i < a.length; i += SPECIES.length()) {
4075                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4076                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4077                 VectorMask<Short> mv = av.compare(VectorOperators.LE, bv, vmask);
4078 
4079                 // Check results as part of computation.
4080                 for (int j = 0; j < SPECIES.length(); j++) {
4081                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
4082                 }
4083             }
4084         }
4085     }
4086 

4087     @Test(dataProvider = "shortCompareOpProvider")
4088     static void GEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4089         short[] a = fa.apply(SPECIES.length());
4090         short[] b = fb.apply(SPECIES.length());
4091 
4092         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4093             for (int i = 0; i < a.length; i += SPECIES.length()) {
4094                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4095                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4096                 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv);
4097 
4098                 // Check results as part of computation.
4099                 for (int j = 0; j < SPECIES.length(); j++) {
4100                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
4101                 }
4102             }
4103         }
4104     }
4105 
4106     @Test(dataProvider = "shortCompareOpMaskProvider")

4109         short[] a = fa.apply(SPECIES.length());
4110         short[] b = fb.apply(SPECIES.length());
4111         boolean[] mask = fm.apply(SPECIES.length());
4112 
4113         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4114 
4115         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4116             for (int i = 0; i < a.length; i += SPECIES.length()) {
4117                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4118                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4119                 VectorMask<Short> mv = av.compare(VectorOperators.GE, bv, vmask);
4120 
4121                 // Check results as part of computation.
4122                 for (int j = 0; j < SPECIES.length(); j++) {
4123                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
4124                 }
4125             }
4126         }
4127     }
4128 


4129     @Test(dataProvider = "shortCompareOpProvider")
4130     static void UNSIGNED_LTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4131         short[] a = fa.apply(SPECIES.length());
4132         short[] b = fb.apply(SPECIES.length());
4133 
4134         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4135             for (int i = 0; i < a.length; i += SPECIES.length()) {
4136                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4137                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4138                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
4139 
4140                 // Check results as part of computation.
4141                 for (int j = 0; j < SPECIES.length(); j++) {
4142                     Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
4143                 }
4144             }
4145         }
4146     }
4147 


4148     @Test(dataProvider = "shortCompareOpMaskProvider")
4149     static void UNSIGNED_LTShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4150                                                 IntFunction<boolean[]> fm) {
4151         short[] a = fa.apply(SPECIES.length());
4152         short[] b = fb.apply(SPECIES.length());
4153         boolean[] mask = fm.apply(SPECIES.length());
4154 
4155         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4156 
4157         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4158             for (int i = 0; i < a.length; i += SPECIES.length()) {
4159                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4160                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4161                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
4162 
4163                 // Check results as part of computation.
4164                 for (int j = 0; j < SPECIES.length(); j++) {
4165                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
4166                 }
4167             }
4168         }
4169     }
4170 



4171     @Test(dataProvider = "shortCompareOpProvider")
4172     static void UNSIGNED_GTShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4173         short[] a = fa.apply(SPECIES.length());
4174         short[] b = fb.apply(SPECIES.length());
4175 
4176         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4177             for (int i = 0; i < a.length; i += SPECIES.length()) {
4178                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4179                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4180                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
4181 
4182                 // Check results as part of computation.
4183                 for (int j = 0; j < SPECIES.length(); j++) {
4184                     Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
4185                 }
4186             }
4187         }
4188     }
4189 


4190     @Test(dataProvider = "shortCompareOpMaskProvider")
4191     static void UNSIGNED_GTShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4192                                                 IntFunction<boolean[]> fm) {
4193         short[] a = fa.apply(SPECIES.length());
4194         short[] b = fb.apply(SPECIES.length());
4195         boolean[] mask = fm.apply(SPECIES.length());
4196 
4197         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4198 
4199         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4200             for (int i = 0; i < a.length; i += SPECIES.length()) {
4201                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4202                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4203                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
4204 
4205                 // Check results as part of computation.
4206                 for (int j = 0; j < SPECIES.length(); j++) {
4207                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
4208                 }
4209             }
4210         }
4211     }
4212 



4213     @Test(dataProvider = "shortCompareOpProvider")
4214     static void UNSIGNED_LEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4215         short[] a = fa.apply(SPECIES.length());
4216         short[] b = fb.apply(SPECIES.length());
4217 
4218         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4219             for (int i = 0; i < a.length; i += SPECIES.length()) {
4220                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4221                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4222                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
4223 
4224                 // Check results as part of computation.
4225                 for (int j = 0; j < SPECIES.length(); j++) {
4226                     Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
4227                 }
4228             }
4229         }
4230     }
4231 


4232     @Test(dataProvider = "shortCompareOpMaskProvider")
4233     static void UNSIGNED_LEShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4234                                                 IntFunction<boolean[]> fm) {
4235         short[] a = fa.apply(SPECIES.length());
4236         short[] b = fb.apply(SPECIES.length());
4237         boolean[] mask = fm.apply(SPECIES.length());
4238 
4239         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4240 
4241         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4242             for (int i = 0; i < a.length; i += SPECIES.length()) {
4243                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4244                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4245                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
4246 
4247                 // Check results as part of computation.
4248                 for (int j = 0; j < SPECIES.length(); j++) {
4249                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
4250                 }
4251             }
4252         }
4253     }
4254 



4255     @Test(dataProvider = "shortCompareOpProvider")
4256     static void UNSIGNED_GEShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4257         short[] a = fa.apply(SPECIES.length());
4258         short[] b = fb.apply(SPECIES.length());
4259 
4260         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4261             for (int i = 0; i < a.length; i += SPECIES.length()) {
4262                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4263                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4264                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
4265 
4266                 // Check results as part of computation.
4267                 for (int j = 0; j < SPECIES.length(); j++) {
4268                     Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
4269                 }
4270             }
4271         }
4272     }
4273 


4274     @Test(dataProvider = "shortCompareOpMaskProvider")
4275     static void UNSIGNED_GEShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4276                                                 IntFunction<boolean[]> fm) {
4277         short[] a = fa.apply(SPECIES.length());
4278         short[] b = fb.apply(SPECIES.length());
4279         boolean[] mask = fm.apply(SPECIES.length());
4280 
4281         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4282 
4283         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4284             for (int i = 0; i < a.length; i += SPECIES.length()) {
4285                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4286                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4287                 VectorMask<Short> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
4288 
4289                 // Check results as part of computation.
4290                 for (int j = 0; j < SPECIES.length(); j++) {
4291                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
4292                 }
4293             }
4294         }
4295     }
4296 


4297     @Test(dataProvider = "shortCompareOpProvider")
4298     static void LTShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4299         short[] a = fa.apply(SPECIES.length());
4300         short[] b = fb.apply(SPECIES.length());
4301 
4302         for (int i = 0; i < a.length; i += SPECIES.length()) {
4303             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4304             VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i]);
4305 
4306             // Check results as part of computation.
4307             for (int j = 0; j < SPECIES.length(); j++) {
4308                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4309             }
4310         }
4311     }
4312 

4313     @Test(dataProvider = "shortCompareOpMaskProvider")
4314     static void LTShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
4315                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4316         short[] a = fa.apply(SPECIES.length());
4317         short[] b = fb.apply(SPECIES.length());
4318         boolean[] mask = fm.apply(SPECIES.length());
4319 
4320         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4321 
4322         for (int i = 0; i < a.length; i += SPECIES.length()) {
4323             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4324             VectorMask<Short> mv = av.compare(VectorOperators.LT, b[i], vmask);
4325 
4326             // Check results as part of computation.
4327             for (int j = 0; j < SPECIES.length(); j++) {
4328                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
4329             }
4330         }
4331     }
4332 
4333     @Test(dataProvider = "shortCompareOpProvider")
4334     static void LTShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4335         short[] a = fa.apply(SPECIES.length());
4336         short[] b = fb.apply(SPECIES.length());
4337 
4338         for (int i = 0; i < a.length; i += SPECIES.length()) {
4339             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4340             VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i]);
4341 
4342             // Check results as part of computation.
4343             for (int j = 0; j < SPECIES.length(); j++) {
4344                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (short)((long)b[i]));
4345             }
4346         }
4347     }
4348 

4349     @Test(dataProvider = "shortCompareOpMaskProvider")
4350     static void LTShort256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
4351                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4352         short[] a = fa.apply(SPECIES.length());
4353         short[] b = fb.apply(SPECIES.length());
4354         boolean[] mask = fm.apply(SPECIES.length());
4355 
4356         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4357 
4358         for (int i = 0; i < a.length; i += SPECIES.length()) {
4359             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4360             VectorMask<Short> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
4361 
4362             // Check results as part of computation.
4363             for (int j = 0; j < SPECIES.length(); j++) {
4364                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (short)((long)b[i])));
4365             }
4366         }
4367     }
4368 
4369     @Test(dataProvider = "shortCompareOpProvider")
4370     static void EQShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4371         short[] a = fa.apply(SPECIES.length());
4372         short[] b = fb.apply(SPECIES.length());
4373 
4374         for (int i = 0; i < a.length; i += SPECIES.length()) {
4375             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4376             VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i]);
4377 
4378             // Check results as part of computation.
4379             for (int j = 0; j < SPECIES.length(); j++) {
4380                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4381             }
4382         }
4383     }
4384 

4385     @Test(dataProvider = "shortCompareOpMaskProvider")
4386     static void EQShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa,
4387                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4388         short[] a = fa.apply(SPECIES.length());
4389         short[] b = fb.apply(SPECIES.length());
4390         boolean[] mask = fm.apply(SPECIES.length());
4391 
4392         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4393 
4394         for (int i = 0; i < a.length; i += SPECIES.length()) {
4395             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4396             VectorMask<Short> mv = av.compare(VectorOperators.EQ, b[i], vmask);
4397 
4398             // Check results as part of computation.
4399             for (int j = 0; j < SPECIES.length(); j++) {
4400                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
4401             }
4402         }
4403     }
4404 
4405     @Test(dataProvider = "shortCompareOpProvider")
4406     static void EQShort256VectorTestsBroadcastLongSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4407         short[] a = fa.apply(SPECIES.length());
4408         short[] b = fb.apply(SPECIES.length());
4409 
4410         for (int i = 0; i < a.length; i += SPECIES.length()) {
4411             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4412             VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i]);
4413 
4414             // Check results as part of computation.
4415             for (int j = 0; j < SPECIES.length(); j++) {
4416                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (short)((long)b[i]));
4417             }
4418         }
4419     }
4420 

4421     @Test(dataProvider = "shortCompareOpMaskProvider")
4422     static void EQShort256VectorTestsBroadcastLongMaskedSmokeTest(IntFunction<short[]> fa,
4423                                 IntFunction<short[]> fb, IntFunction<boolean[]> fm) {
4424         short[] a = fa.apply(SPECIES.length());
4425         short[] b = fb.apply(SPECIES.length());
4426         boolean[] mask = fm.apply(SPECIES.length());
4427 
4428         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4429 
4430         for (int i = 0; i < a.length; i += SPECIES.length()) {
4431             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4432             VectorMask<Short> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
4433 
4434             // Check results as part of computation.
4435             for (int j = 0; j < SPECIES.length(); j++) {
4436                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (short)((long)b[i])));
4437             }
4438         }
4439     }
4440 

4479         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
4480     }
4481 
4482     @Test(dataProvider = "shortUnaryOpShuffleMaskProvider")
4483     static void RearrangeShort256VectorTestsMaskedSmokeTest(IntFunction<short[]> fa,
4484                                                           BiFunction<Integer,Integer,int[]> fs,
4485                                                           IntFunction<boolean[]> fm) {
4486         short[] a = fa.apply(SPECIES.length());
4487         int[] order = fs.apply(a.length, SPECIES.length());
4488         short[] r = fr.apply(SPECIES.length());
4489         boolean[] mask = fm.apply(SPECIES.length());
4490         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4491 
4492         for (int i = 0; i < a.length; i += SPECIES.length()) {
4493             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4494             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
4495         }
4496 
4497         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
4498     }
4499 
4500     @Test(dataProvider = "shortUnaryOpMaskProvider")
4501     static void compressShort256VectorTests(IntFunction<short[]> fa,
4502                                                 IntFunction<boolean[]> fm) {
4503         short[] a = fa.apply(SPECIES.length());
4504         short[] r = fr.apply(SPECIES.length());
4505         boolean[] mask = fm.apply(SPECIES.length());
4506         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4507 
4508         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4509             for (int i = 0; i < a.length; i += SPECIES.length()) {
4510                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4511                 av.compress(vmask).intoArray(r, i);
4512             }
4513         }
4514 
4515         assertcompressArraysEquals(r, a, mask, SPECIES.length());
4516     }
4517 
4518     @Test(dataProvider = "shortUnaryOpMaskProvider")
4519     static void expandShort256VectorTests(IntFunction<short[]> fa,
4520                                                 IntFunction<boolean[]> fm) {
4521         short[] a = fa.apply(SPECIES.length());
4522         short[] r = fr.apply(SPECIES.length());
4523         boolean[] mask = fm.apply(SPECIES.length());
4524         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4525 
4526         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4527             for (int i = 0; i < a.length; i += SPECIES.length()) {
4528                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4529                 av.expand(vmask).intoArray(r, i);
4530             }
4531         }
4532 
4533         assertexpandArraysEquals(r, a, mask, SPECIES.length());
4534     }
4535 
4536     @Test(dataProvider = "shortUnaryOpProvider")
4537     static void getShort256VectorTests(IntFunction<short[]> fa) {
4538         short[] a = fa.apply(SPECIES.length());
4539         short[] r = fr.apply(SPECIES.length());
4540 
4541         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4542             for (int i = 0; i < a.length; i += SPECIES.length()) {
4543                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4544                 int num_lanes = SPECIES.length();
4545                 // Manually unroll because full unroll happens after intrinsification.
4546                 // Unroll is needed because get intrinsic requires for index to be a known constant.
4547                 if (num_lanes == 1) {
4548                     r[i]=av.lane(0);
4549                 } else if (num_lanes == 2) {
4550                     r[i]=av.lane(0);
4551                     r[i+1]=av.lane(1);
4552                 } else if (num_lanes == 4) {
4553                     r[i]=av.lane(0);
4554                     r[i+1]=av.lane(1);
4555                     r[i+2]=av.lane(2);

4686             }
4687         }
4688 
4689         assertArraysEquals(r, a, Short256VectorTests::get);
4690     }
4691 
4692     @Test(dataProvider = "shortUnaryOpProvider")
4693     static void BroadcastShort256VectorTests(IntFunction<short[]> fa) {
4694         short[] a = fa.apply(SPECIES.length());
4695         short[] r = new short[a.length];
4696 
4697         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4698             for (int i = 0; i < a.length; i += SPECIES.length()) {
4699                 ShortVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4700             }
4701         }
4702 
4703         assertBroadcastArraysEquals(r, a);
4704     }
4705 




4706     @Test(dataProvider = "shortUnaryOpProvider")
4707     static void ZeroShort256VectorTests(IntFunction<short[]> fa) {
4708         short[] a = fa.apply(SPECIES.length());
4709         short[] r = new short[a.length];
4710 
4711         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4712             for (int i = 0; i < a.length; i += SPECIES.length()) {
4713                 ShortVector.zero(SPECIES).intoArray(a, i);
4714             }
4715         }
4716 
4717         Assert.assertEquals(a, r);
4718     }
4719 



4720     static short[] sliceUnary(short[] a, int origin, int idx) {
4721         short[] res = new short[SPECIES.length()];
4722         for (int i = 0; i < SPECIES.length(); i++){
4723             if(i+origin < SPECIES.length())
4724                 res[i] = a[idx+i+origin];
4725             else
4726                 res[i] = (short)0;
4727         }
4728         return res;
4729     }
4730 
4731     @Test(dataProvider = "shortUnaryOpProvider")
4732     static void sliceUnaryShort256VectorTests(IntFunction<short[]> fa) {
4733         short[] a = fa.apply(SPECIES.length());
4734         short[] r = new short[a.length];
4735         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4736         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4737             for (int i = 0; i < a.length; i += SPECIES.length()) {
4738                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4739                 av.slice(origin).intoArray(r, i);
4740             }
4741         }
4742 
4743         assertArraysEquals(r, a, origin, Short256VectorTests::sliceUnary);
4744     }
4745 
4746     static short[] sliceBinary(short[] a, short[] b, int origin, int idx) {
4747         short[] res = new short[SPECIES.length()];
4748         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4749             if(i+origin < SPECIES.length())
4750                 res[i] = a[idx+i+origin];
4751             else {
4752                 res[i] = b[idx+j];
4753                 j++;
4754             }
4755         }
4756         return res;
4757     }
4758 
4759     @Test(dataProvider = "shortBinaryOpProvider")
4760     static void sliceBinaryShort256VectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4761         short[] a = fa.apply(SPECIES.length());
4762         short[] b = fb.apply(SPECIES.length());
4763         short[] r = new short[a.length];
4764         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4765         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4766             for (int i = 0; i < a.length; i += SPECIES.length()) {
4767                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4768                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4769                 av.slice(origin, bv).intoArray(r, i);
4770             }
4771         }
4772 
4773         assertArraysEquals(r, a, b, origin, Short256VectorTests::sliceBinary);
4774     }
4775 
4776     static short[] slice(short[] a, short[] b, int origin, boolean[] mask, int idx) {
4777         short[] res = new short[SPECIES.length()];
4778         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4779             if(i+origin < SPECIES.length())
4780                 res[i] = mask[i] ? a[idx+i+origin] : (short)0;
4781             else {
4782                 res[i] = mask[i] ? b[idx+j] : (short)0;
4783                 j++;
4784             }
4785         }
4786         return res;
4787     }
4788 
4789     @Test(dataProvider = "shortBinaryOpMaskProvider")
4790     static void sliceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4791     IntFunction<boolean[]> fm) {
4792         short[] a = fa.apply(SPECIES.length());
4793         short[] b = fb.apply(SPECIES.length());
4794         boolean[] mask = fm.apply(SPECIES.length());
4795         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4796 
4797         short[] r = new short[a.length];
4798         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4799         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4800             for (int i = 0; i < a.length; i += SPECIES.length()) {
4801                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4802                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4803                 av.slice(origin, bv, vmask).intoArray(r, i);
4804             }
4805         }
4806 
4807         assertArraysEquals(r, a, b, origin, mask, Short256VectorTests::slice);
4808     }
4809 
4810     static short[] unsliceUnary(short[] a, int origin, int idx) {
4811         short[] res = new short[SPECIES.length()];
4812         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4813             if(i < origin)
4814                 res[i] = (short)0;
4815             else {
4816                 res[i] = a[idx+j];
4817                 j++;
4818             }
4819         }
4820         return res;
4821     }
4822 
4823     @Test(dataProvider = "shortUnaryOpProvider")
4824     static void unsliceUnaryShort256VectorTests(IntFunction<short[]> fa) {
4825         short[] a = fa.apply(SPECIES.length());
4826         short[] r = new short[a.length];
4827         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4828         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4829             for (int i = 0; i < a.length; i += SPECIES.length()) {
4830                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4831                 av.unslice(origin).intoArray(r, i);
4832             }
4833         }
4834 
4835         assertArraysEquals(r, a, origin, Short256VectorTests::unsliceUnary);
4836     }
4837 
4838     static short[] unsliceBinary(short[] a, short[] b, int origin, int part, int idx) {
4839         short[] res = new short[SPECIES.length()];
4840         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4841             if (part == 0) {
4842                 if (i < origin)
4843                     res[i] = b[idx+i];
4844                 else {
4845                     res[i] = a[idx+j];
4846                     j++;
4847                 }
4848             } else if (part == 1) {
4849                 if (i < origin)
4850                     res[i] = a[idx+SPECIES.length()-origin+i];
4851                 else {
4852                     res[i] = b[idx+origin+j];
4853                     j++;
4854                 }
4855             }
4856         }
4857         return res;
4858     }
4859 
4860     @Test(dataProvider = "shortBinaryOpProvider")
4861     static void unsliceBinaryShort256VectorTestsBinary(IntFunction<short[]> fa, IntFunction<short[]> fb) {
4862         short[] a = fa.apply(SPECIES.length());
4863         short[] b = fb.apply(SPECIES.length());
4864         short[] r = new short[a.length];
4865         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4866         int part = (new java.util.Random()).nextInt(2);
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                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4871                 av.unslice(origin, bv, part).intoArray(r, i);
4872             }
4873         }
4874 
4875         assertArraysEquals(r, a, b, origin, part, Short256VectorTests::unsliceBinary);
4876     }
4877 
4878     static short[] unslice(short[] a, short[] b, int origin, int part, boolean[] mask, int idx) {
4879         short[] res = new short[SPECIES.length()];
4880         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4881             if(i+origin < SPECIES.length())
4882                 res[i] = b[idx+i+origin];
4883             else {
4884                 res[i] = b[idx+j];
4885                 j++;
4886             }
4887         }
4888         for (int i = 0; i < SPECIES.length(); i++){
4889             res[i] = mask[i] ? a[idx+i] : res[i];
4890         }
4891         short[] res1 = new short[SPECIES.length()];
4892         if (part == 0) {
4893             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4894                 if (i < origin)
4895                     res1[i] = b[idx+i];
4896                 else {
4897                    res1[i] = res[j];

4915     static void unsliceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4916     IntFunction<boolean[]> fm) {
4917         short[] a = fa.apply(SPECIES.length());
4918         short[] b = fb.apply(SPECIES.length());
4919         boolean[] mask = fm.apply(SPECIES.length());
4920         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4921         short[] r = new short[a.length];
4922         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4923         int part = (new java.util.Random()).nextInt(2);
4924         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4925             for (int i = 0; i < a.length; i += SPECIES.length()) {
4926                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4927                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4928                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
4929             }
4930         }
4931 
4932         assertArraysEquals(r, a, b, origin, part, mask, Short256VectorTests::unslice);
4933     }
4934 






















4935     static short BITWISE_BLEND(short a, short b, short c) {
4936         return (short)((a&~(c))|(b&c));
4937     }
4938 
4939     static short bitwiseBlend(short a, short b, short c) {
4940         return (short)((a&~(c))|(b&c));
4941     }
4942 

4943     @Test(dataProvider = "shortTernaryOpProvider")
4944     static void BITWISE_BLENDShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
4945         short[] a = fa.apply(SPECIES.length());
4946         short[] b = fb.apply(SPECIES.length());
4947         short[] c = fc.apply(SPECIES.length());
4948         short[] r = fr.apply(SPECIES.length());
4949 
4950         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4951             for (int i = 0; i < a.length; i += SPECIES.length()) {
4952                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4953                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4954                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
4955                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
4956             }
4957         }
4958 
4959         assertArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
4960     }
4961 
4962     @Test(dataProvider = "shortTernaryOpProvider")
4963     static void bitwiseBlendShort256VectorTests(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
4964         short[] a = fa.apply(SPECIES.length());
4965         short[] b = fb.apply(SPECIES.length());
4966         short[] c = fc.apply(SPECIES.length());
4967         short[] r = fr.apply(SPECIES.length());
4968 
4969         for (int i = 0; i < a.length; i += SPECIES.length()) {
4970             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4971             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4972             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
4973             av.bitwiseBlend(bv, cv).intoArray(r, i);
4974         }
4975 
4976         assertArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
4977     }
4978 

4979     @Test(dataProvider = "shortTernaryOpMaskProvider")
4980     static void BITWISE_BLENDShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<short[]> fb,
4981                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
4982         short[] a = fa.apply(SPECIES.length());
4983         short[] b = fb.apply(SPECIES.length());
4984         short[] c = fc.apply(SPECIES.length());
4985         short[] r = fr.apply(SPECIES.length());
4986         boolean[] mask = fm.apply(SPECIES.length());
4987         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4988 
4989         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4990             for (int i = 0; i < a.length; i += SPECIES.length()) {
4991                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
4992                 ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
4993                 ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
4994                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
4995             }
4996         }
4997 
4998         assertArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
4999     }
5000 



5001     @Test(dataProvider = "shortTernaryOpProvider")
5002     static void BITWISE_BLENDShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5003         short[] a = fa.apply(SPECIES.length());
5004         short[] b = fb.apply(SPECIES.length());
5005         short[] c = fc.apply(SPECIES.length());
5006         short[] r = fr.apply(SPECIES.length());
5007 
5008         for (int i = 0; i < a.length; i += SPECIES.length()) {
5009             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5010             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5011             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
5012         }
5013         assertBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
5014     }
5015 
5016     @Test(dataProvider = "shortTernaryOpProvider")
5017     static void BITWISE_BLENDShort256VectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5018         short[] a = fa.apply(SPECIES.length());
5019         short[] b = fb.apply(SPECIES.length());
5020         short[] c = fc.apply(SPECIES.length());
5021         short[] r = fr.apply(SPECIES.length());
5022 
5023         for (int i = 0; i < a.length; i += SPECIES.length()) {
5024             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5025             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5026             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
5027         }
5028         assertAltBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
5029     }
5030 
5031     @Test(dataProvider = "shortTernaryOpProvider")
5032     static void bitwiseBlendShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5033         short[] a = fa.apply(SPECIES.length());
5034         short[] b = fb.apply(SPECIES.length());
5035         short[] c = fc.apply(SPECIES.length());
5036         short[] r = fr.apply(SPECIES.length());
5037 
5038         for (int i = 0; i < a.length; i += SPECIES.length()) {
5039             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5040             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5041             av.bitwiseBlend(bv, c[i]).intoArray(r, i);
5042         }
5043         assertBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
5044     }
5045 
5046     @Test(dataProvider = "shortTernaryOpProvider")
5047     static void bitwiseBlendShort256VectorTestsAltBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5048         short[] a = fa.apply(SPECIES.length());
5049         short[] b = fb.apply(SPECIES.length());
5050         short[] c = fc.apply(SPECIES.length());
5051         short[] r = fr.apply(SPECIES.length());
5052 
5053         for (int i = 0; i < a.length; i += SPECIES.length()) {
5054             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5055             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5056             av.bitwiseBlend(b[i], cv).intoArray(r, i);
5057         }
5058         assertAltBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
5059     }
5060 

5061     @Test(dataProvider = "shortTernaryOpMaskProvider")
5062     static void BITWISE_BLENDShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5063                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5064         short[] a = fa.apply(SPECIES.length());
5065         short[] b = fb.apply(SPECIES.length());
5066         short[] c = fc.apply(SPECIES.length());
5067         short[] r = fr.apply(SPECIES.length());
5068         boolean[] mask = fm.apply(SPECIES.length());
5069         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5070 
5071         for (int i = 0; i < a.length; i += SPECIES.length()) {
5072             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5073             ShortVector bv = ShortVector.fromArray(SPECIES, b, i);
5074             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
5075         }
5076 
5077         assertBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
5078     }
5079 
5080     @Test(dataProvider = "shortTernaryOpMaskProvider")
5081     static void BITWISE_BLENDShort256VectorTestsAltBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5082                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5083         short[] a = fa.apply(SPECIES.length());
5084         short[] b = fb.apply(SPECIES.length());
5085         short[] c = fc.apply(SPECIES.length());
5086         short[] r = fr.apply(SPECIES.length());
5087         boolean[] mask = fm.apply(SPECIES.length());
5088         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5089 
5090         for (int i = 0; i < a.length; i += SPECIES.length()) {
5091             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5092             ShortVector cv = ShortVector.fromArray(SPECIES, c, i);
5093             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
5094         }
5095 
5096         assertAltBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
5097     }
5098 



5099     @Test(dataProvider = "shortTernaryOpProvider")
5100     static void BITWISE_BLENDShort256VectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5101         short[] a = fa.apply(SPECIES.length());
5102         short[] b = fb.apply(SPECIES.length());
5103         short[] c = fc.apply(SPECIES.length());
5104         short[] r = fr.apply(SPECIES.length());
5105 
5106         for (int i = 0; i < a.length; i += SPECIES.length()) {
5107             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5108             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
5109         }
5110 
5111         assertDoubleBroadcastArraysEquals(r, a, b, c, Short256VectorTests::BITWISE_BLEND);
5112     }
5113 
5114     @Test(dataProvider = "shortTernaryOpProvider")
5115     static void bitwiseBlendShort256VectorTestsDoubleBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb, IntFunction<short[]> fc) {
5116         short[] a = fa.apply(SPECIES.length());
5117         short[] b = fb.apply(SPECIES.length());
5118         short[] c = fc.apply(SPECIES.length());
5119         short[] r = fr.apply(SPECIES.length());
5120 
5121         for (int i = 0; i < a.length; i += SPECIES.length()) {
5122             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5123             av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
5124         }
5125 
5126         assertDoubleBroadcastArraysEquals(r, a, b, c, Short256VectorTests::bitwiseBlend);
5127     }
5128 

5129     @Test(dataProvider = "shortTernaryOpMaskProvider")
5130     static void BITWISE_BLENDShort256VectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb,
5131                                           IntFunction<short[]> fc, IntFunction<boolean[]> fm) {
5132         short[] a = fa.apply(SPECIES.length());
5133         short[] b = fb.apply(SPECIES.length());
5134         short[] c = fc.apply(SPECIES.length());
5135         short[] r = fr.apply(SPECIES.length());
5136         boolean[] mask = fm.apply(SPECIES.length());
5137         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5138 
5139         for (int i = 0; i < a.length; i += SPECIES.length()) {
5140             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5141             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
5142         }
5143 
5144         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, Short256VectorTests::BITWISE_BLEND);
5145     }
5146 

5147     static short NEG(short a) {
5148         return (short)(-((short)a));
5149     }
5150 
5151     static short neg(short a) {
5152         return (short)(-((short)a));
5153     }
5154 
5155     @Test(dataProvider = "shortUnaryOpProvider")
5156     static void NEGShort256VectorTests(IntFunction<short[]> fa) {
5157         short[] a = fa.apply(SPECIES.length());
5158         short[] r = fr.apply(SPECIES.length());
5159 
5160         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5161             for (int i = 0; i < a.length; i += SPECIES.length()) {
5162                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5163                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
5164             }
5165         }
5166 

5239     }
5240 
5241     @Test(dataProvider = "shortUnaryOpMaskProvider")
5242     static void ABSMaskedShort256VectorTests(IntFunction<short[]> fa,
5243                                                 IntFunction<boolean[]> fm) {
5244         short[] a = fa.apply(SPECIES.length());
5245         short[] r = fr.apply(SPECIES.length());
5246         boolean[] mask = fm.apply(SPECIES.length());
5247         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5248 
5249         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5250             for (int i = 0; i < a.length; i += SPECIES.length()) {
5251                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5252                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
5253             }
5254         }
5255 
5256         assertArraysEquals(r, a, mask, Short256VectorTests::ABS);
5257     }
5258 

5259     static short NOT(short a) {
5260         return (short)(~((short)a));
5261     }
5262 
5263     static short not(short a) {
5264         return (short)(~((short)a));
5265     }
5266 


5267     @Test(dataProvider = "shortUnaryOpProvider")
5268     static void NOTShort256VectorTests(IntFunction<short[]> fa) {
5269         short[] a = fa.apply(SPECIES.length());
5270         short[] r = fr.apply(SPECIES.length());
5271 
5272         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5273             for (int i = 0; i < a.length; i += SPECIES.length()) {
5274                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5275                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
5276             }
5277         }
5278 
5279         assertArraysEquals(r, a, Short256VectorTests::NOT);
5280     }
5281 
5282     @Test(dataProvider = "shortUnaryOpProvider")
5283     static void notShort256VectorTests(IntFunction<short[]> fa) {
5284         short[] a = fa.apply(SPECIES.length());
5285         short[] r = fr.apply(SPECIES.length());
5286 
5287         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5288             for (int i = 0; i < a.length; i += SPECIES.length()) {
5289                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5290                 av.not().intoArray(r, i);
5291             }
5292         }
5293 
5294         assertArraysEquals(r, a, Short256VectorTests::not);
5295     }
5296 


5297     @Test(dataProvider = "shortUnaryOpMaskProvider")
5298     static void NOTMaskedShort256VectorTests(IntFunction<short[]> fa,
5299                                                 IntFunction<boolean[]> fm) {
5300         short[] a = fa.apply(SPECIES.length());
5301         short[] r = fr.apply(SPECIES.length());
5302         boolean[] mask = fm.apply(SPECIES.length());
5303         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5304 
5305         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5306             for (int i = 0; i < a.length; i += SPECIES.length()) {
5307                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5308                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
5309             }
5310         }
5311 
5312         assertArraysEquals(r, a, mask, Short256VectorTests::NOT);
5313     }
5314 


5315     static short ZOMO(short a) {
5316         return (short)((a==0?0:-1));
5317     }
5318 


5319     @Test(dataProvider = "shortUnaryOpProvider")
5320     static void ZOMOShort256VectorTests(IntFunction<short[]> fa) {
5321         short[] a = fa.apply(SPECIES.length());
5322         short[] r = fr.apply(SPECIES.length());
5323 
5324         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5325             for (int i = 0; i < a.length; i += SPECIES.length()) {
5326                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5327                 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
5328             }
5329         }
5330 
5331         assertArraysEquals(r, a, Short256VectorTests::ZOMO);
5332     }
5333 


5334     @Test(dataProvider = "shortUnaryOpMaskProvider")
5335     static void ZOMOMaskedShort256VectorTests(IntFunction<short[]> fa,
5336                                                 IntFunction<boolean[]> fm) {
5337         short[] a = fa.apply(SPECIES.length());
5338         short[] r = fr.apply(SPECIES.length());
5339         boolean[] mask = fm.apply(SPECIES.length());
5340         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5341 
5342         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5343             for (int i = 0; i < a.length; i += SPECIES.length()) {
5344                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5345                 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
5346             }
5347         }
5348 
5349         assertArraysEquals(r, a, mask, Short256VectorTests::ZOMO);
5350     }
5351 
5352     static short BIT_COUNT(short a) {
5353         return (short)(Integer.bitCount((int)a & 0xFFFF));
5354     }
5355 
5356     @Test(dataProvider = "shortUnaryOpProvider")
5357     static void BIT_COUNTShort256VectorTests(IntFunction<short[]> fa) {
5358         short[] a = fa.apply(SPECIES.length());
5359         short[] r = fr.apply(SPECIES.length());
5360 
5361         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5362             for (int i = 0; i < a.length; i += SPECIES.length()) {
5363                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5364                 av.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i);
5365             }
5366         }
5367 
5368         assertArraysEquals(r, a, Short256VectorTests::BIT_COUNT);
5369     }
5370 
5371     @Test(dataProvider = "shortUnaryOpMaskProvider")
5372     static void BIT_COUNTMaskedShort256VectorTests(IntFunction<short[]> fa,
5373                                                 IntFunction<boolean[]> fm) {
5374         short[] a = fa.apply(SPECIES.length());
5375         short[] r = fr.apply(SPECIES.length());
5376         boolean[] mask = fm.apply(SPECIES.length());
5377         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5378 
5379         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5380             for (int i = 0; i < a.length; i += SPECIES.length()) {
5381                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5382                 av.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i);
5383             }
5384         }
5385 
5386         assertArraysEquals(r, a, mask, Short256VectorTests::BIT_COUNT);
5387     }
5388 
5389     static short TRAILING_ZEROS_COUNT(short a) {
5390         return (short)(TRAILING_ZEROS_COUNT_scalar(a));
5391     }
5392 
5393     @Test(dataProvider = "shortUnaryOpProvider")
5394     static void TRAILING_ZEROS_COUNTShort256VectorTests(IntFunction<short[]> fa) {
5395         short[] a = fa.apply(SPECIES.length());
5396         short[] r = fr.apply(SPECIES.length());
5397 
5398         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5399             for (int i = 0; i < a.length; i += SPECIES.length()) {
5400                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5401                 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i);
5402             }
5403         }
5404 
5405         assertArraysEquals(r, a, Short256VectorTests::TRAILING_ZEROS_COUNT);
5406     }
5407 
5408     @Test(dataProvider = "shortUnaryOpMaskProvider")
5409     static void TRAILING_ZEROS_COUNTMaskedShort256VectorTests(IntFunction<short[]> fa,
5410                                                 IntFunction<boolean[]> fm) {
5411         short[] a = fa.apply(SPECIES.length());
5412         short[] r = fr.apply(SPECIES.length());
5413         boolean[] mask = fm.apply(SPECIES.length());
5414         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5415 
5416         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5417             for (int i = 0; i < a.length; i += SPECIES.length()) {
5418                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5419                 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i);
5420             }
5421         }
5422 
5423         assertArraysEquals(r, a, mask, Short256VectorTests::TRAILING_ZEROS_COUNT);
5424     }
5425 
5426     static short LEADING_ZEROS_COUNT(short a) {
5427         return (short)(LEADING_ZEROS_COUNT_scalar(a));
5428     }
5429 
5430     @Test(dataProvider = "shortUnaryOpProvider")
5431     static void LEADING_ZEROS_COUNTShort256VectorTests(IntFunction<short[]> fa) {
5432         short[] a = fa.apply(SPECIES.length());
5433         short[] r = fr.apply(SPECIES.length());
5434 
5435         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5436             for (int i = 0; i < a.length; i += SPECIES.length()) {
5437                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5438                 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i);
5439             }
5440         }
5441 
5442         assertArraysEquals(r, a, Short256VectorTests::LEADING_ZEROS_COUNT);
5443     }
5444 
5445     @Test(dataProvider = "shortUnaryOpMaskProvider")
5446     static void LEADING_ZEROS_COUNTMaskedShort256VectorTests(IntFunction<short[]> fa,
5447                                                 IntFunction<boolean[]> fm) {
5448         short[] a = fa.apply(SPECIES.length());
5449         short[] r = fr.apply(SPECIES.length());
5450         boolean[] mask = fm.apply(SPECIES.length());
5451         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5452 
5453         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5454             for (int i = 0; i < a.length; i += SPECIES.length()) {
5455                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5456                 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i);
5457             }
5458         }
5459 
5460         assertArraysEquals(r, a, mask, Short256VectorTests::LEADING_ZEROS_COUNT);
5461     }
5462 
5463     static short REVERSE(short a) {
5464         return (short)(REVERSE_scalar(a));
5465     }
5466 
5467     @Test(dataProvider = "shortUnaryOpProvider")
5468     static void REVERSEShort256VectorTests(IntFunction<short[]> fa) {
5469         short[] a = fa.apply(SPECIES.length());
5470         short[] r = fr.apply(SPECIES.length());
5471 
5472         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5473             for (int i = 0; i < a.length; i += SPECIES.length()) {
5474                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5475                 av.lanewise(VectorOperators.REVERSE).intoArray(r, i);
5476             }
5477         }
5478 
5479         assertArraysEquals(r, a, Short256VectorTests::REVERSE);
5480     }
5481 
5482     @Test(dataProvider = "shortUnaryOpMaskProvider")
5483     static void REVERSEMaskedShort256VectorTests(IntFunction<short[]> fa,
5484                                                 IntFunction<boolean[]> fm) {
5485         short[] a = fa.apply(SPECIES.length());
5486         short[] r = fr.apply(SPECIES.length());
5487         boolean[] mask = fm.apply(SPECIES.length());
5488         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5489 
5490         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5491             for (int i = 0; i < a.length; i += SPECIES.length()) {
5492                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5493                 av.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i);
5494             }
5495         }
5496 
5497         assertArraysEquals(r, a, mask, Short256VectorTests::REVERSE);
5498     }
5499 
5500     static short REVERSE_BYTES(short a) {
5501         return (short)(Short.reverseBytes(a));
5502     }
5503 
5504     @Test(dataProvider = "shortUnaryOpProvider")
5505     static void REVERSE_BYTESShort256VectorTests(IntFunction<short[]> fa) {
5506         short[] a = fa.apply(SPECIES.length());
5507         short[] r = fr.apply(SPECIES.length());
5508 
5509         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5510             for (int i = 0; i < a.length; i += SPECIES.length()) {
5511                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5512                 av.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i);
5513             }
5514         }
5515 
5516         assertArraysEquals(r, a, Short256VectorTests::REVERSE_BYTES);
5517     }
5518 
5519     @Test(dataProvider = "shortUnaryOpMaskProvider")
5520     static void REVERSE_BYTESMaskedShort256VectorTests(IntFunction<short[]> fa,
5521                                                 IntFunction<boolean[]> fm) {
5522         short[] a = fa.apply(SPECIES.length());
5523         short[] r = fr.apply(SPECIES.length());
5524         boolean[] mask = fm.apply(SPECIES.length());
5525         VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5526 
5527         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5528             for (int i = 0; i < a.length; i += SPECIES.length()) {
5529                 ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5530                 av.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i);
5531             }
5532         }
5533 
5534         assertArraysEquals(r, a, mask, Short256VectorTests::REVERSE_BYTES);
5535     }
5536 
5537     @Test(dataProvider = "shortCompareOpProvider")
5538     static void ltShort256VectorTestsBroadcastSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5539         short[] a = fa.apply(SPECIES.length());
5540         short[] b = fb.apply(SPECIES.length());
5541 
5542         for (int i = 0; i < a.length; i += SPECIES.length()) {
5543             ShortVector av = ShortVector.fromArray(SPECIES, a, i);
5544             VectorMask<Short> mv = av.lt(b[i]);
5545 
5546             // Check results as part of computation.
5547             for (int j = 0; j < SPECIES.length(); j++) {
5548                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5549             }
5550         }
5551     }
5552 
5553     @Test(dataProvider = "shortCompareOpProvider")
5554     static void eqShort256VectorTestsBroadcastMaskedSmokeTest(IntFunction<short[]> fa, IntFunction<short[]> fb) {
5555         short[] a = fa.apply(SPECIES.length());

5918             }
5919         }
5920         return i - idx;
5921     }
5922 
5923     @Test(dataProvider = "maskProvider")
5924     static void maskFirstTrueShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5925         boolean[] a = fa.apply(SPECIES.length());
5926         int[] r = new int[a.length];
5927 
5928         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5929             for (int i = 0; i < a.length; i += SPECIES.length()) {
5930                 var vmask = SPECIES.loadMask(a, i);
5931                 r[i] = vmask.firstTrue();
5932             }
5933         }
5934 
5935         assertMaskReductionArraysEquals(r, a, Short256VectorTests::maskFirstTrue);
5936     }
5937 
5938     @Test(dataProvider = "maskProvider")
5939     static void maskCompressShort256VectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5940         int trueCount = 0;
5941         boolean[] a = fa.apply(SPECIES.length());
5942 
5943         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5944             for (int i = 0; i < a.length; i += SPECIES.length()) {
5945                 var vmask = SPECIES.loadMask(a, i);
5946                 trueCount = vmask.trueCount();
5947                 var rmask = vmask.compress();
5948                 for (int j = 0; j < SPECIES.length(); j++)  {
5949                     Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
5950                 }
5951             }
5952         }
5953     }
5954 
5955     @DataProvider
5956     public static Object[][] longMaskProvider() {
5957         return new Object[][]{
5958                 {0xFFFFFFFFFFFFFFFFL},
5959                 {0x0000000000000000L},
5960                 {0x5555555555555555L},
5961                 {0x0123456789abcdefL},
5962         };
5963     }
5964 
5965     @Test(dataProvider = "longMaskProvider")
5966     static void maskFromToLongShort256VectorTestsSmokeTest(long inputLong) {
5967         var vmask = VectorMask.fromLong(SPECIES, inputLong);
5968         long outputLong = vmask.toLong();
5969         Assert.assertEquals(outputLong, (inputLong & (((0xFFFFFFFFFFFFFFFFL >>> (64 - SPECIES.length()))))));
5970     }
5971 
5972     @DataProvider
5973     public static Object[][] offsetProvider() {
5974         return new Object[][]{

5977                 {+1},
5978                 {+2},
5979                 {-2},
5980         };
5981     }
5982 
5983     @Test(dataProvider = "offsetProvider")
5984     static void indexInRangeShort256VectorTestsSmokeTest(int offset) {
5985         int limit = SPECIES.length() * BUFFER_REPS;
5986         for (int i = 0; i < limit; i += SPECIES.length()) {
5987             var actualMask = SPECIES.indexInRange(i + offset, limit);
5988             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5989             assert(actualMask.equals(expectedMask));
5990             for (int j = 0; j < SPECIES.length(); j++)  {
5991                 int index = i + j + offset;
5992                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5993             }
5994         }
5995     }
5996 
5997     @Test(dataProvider = "offsetProvider")
5998     static void indexInRangeLongShort256VectorTestsSmokeTest(int offset) {
5999         long limit = SPECIES.length() * BUFFER_REPS;
6000         for (long i = 0; i < limit; i += SPECIES.length()) {
6001             var actualMask = SPECIES.indexInRange(i + offset, limit);
6002             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
6003             assert(actualMask.equals(expectedMask));
6004             for (int j = 0; j < SPECIES.length(); j++)  {
6005                 long index = i + j + offset;
6006                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
6007             }
6008         }
6009     }
6010 
6011     @DataProvider
6012     public static Object[][] lengthProvider() {
6013         return new Object[][]{
6014                 {0},
6015                 {1},
6016                 {32},
6017                 {37},
6018                 {1024},
6019                 {1024+1},
6020                 {1024+5},
6021         };
6022     }
6023 
6024     @Test(dataProvider = "lengthProvider")
6025     static void loopBoundShort256VectorTestsSmokeTest(int length) {
6026         int actualLoopBound = SPECIES.loopBound(length);
6027         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6028         Assert.assertEquals(actualLoopBound, expectedLoopBound);
6029     }
6030 
6031     @Test(dataProvider = "lengthProvider")
6032     static void loopBoundLongShort256VectorTestsSmokeTest(int _length) {
6033         long length = _length;
6034         long actualLoopBound = SPECIES.loopBound(length);
6035         long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6036         Assert.assertEquals(actualLoopBound, expectedLoopBound);
6037     }
6038 
6039     @Test
6040     static void ElementSizeShort256VectorTestsSmokeTest() {
6041         ShortVector av = ShortVector.zero(SPECIES);
6042         int elsize = av.elementSize();
6043         Assert.assertEquals(elsize, Short.SIZE);
6044     }
6045 
6046     @Test
6047     static void VectorShapeShort256VectorTestsSmokeTest() {
6048         ShortVector av = ShortVector.zero(SPECIES);
6049         VectorShape vsh = av.shape();
6050         assert(vsh.equals(VectorShape.S_256_BIT));
6051     }
6052 
6053     @Test
6054     static void ShapeWithLanesShort256VectorTestsSmokeTest() {
6055         ShortVector av = ShortVector.zero(SPECIES);
6056         VectorShape vsh = av.shape();
6057         VectorSpecies species = vsh.withLanes(short.class);
6058         assert(species.equals(SPECIES));

6081         ShortVector av = ShortVector.zero(SPECIES);
6082         VectorSpecies species = av.species().withLanes(short.class);
6083         assert(species.equals(SPECIES));
6084     }
6085 
6086     @Test
6087     static void WithShapeShort256VectorTestsSmokeTest() {
6088         ShortVector av = ShortVector.zero(SPECIES);
6089         VectorShape vsh = av.shape();
6090         VectorSpecies species = av.species().withShape(vsh);
6091         assert(species.equals(SPECIES));
6092     }
6093 
6094     @Test
6095     static void MaskAllTrueShort256VectorTestsSmokeTest() {
6096         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6097           Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
6098         }
6099     }
6100 }

< prev index next >