< prev index next >

test/jdk/jdk/incubator/vector/IntMaxVectorTests.java

Print this page

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

















































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

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

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

1014 
1015     @DataProvider
1016     public Object[][] intUnaryOpShuffleProvider() {
1017         return INT_SHUFFLE_GENERATORS.stream().
1018                 flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
1019                     return new Object[] {fa, fs};
1020                 })).
1021                 toArray(Object[][]::new);
1022     }
1023 
1024     @DataProvider
1025     public Object[][] intUnaryOpShuffleMaskProvider() {
1026         return BOOLEAN_MASK_GENERATORS.stream().
1027                 flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().
1028                     flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
1029                         return new Object[] {fa, fs, fm};
1030                 }))).
1031                 toArray(Object[][]::new);
1032     }
1033 
1034 
1035     static final List<IntFunction<int[]>> INT_COMPARE_GENERATORS = List.of(
1036             withToString("int[i]", (int s) -> {
1037                 return fill(s * BUFFER_REPS,
1038                             i -> (int)i);
1039             }),
1040             withToString("int[i - length / 2]", (int s) -> {
1041                 return fill(s * BUFFER_REPS,
1042                             i -> (int)(i - (s * BUFFER_REPS / 2)));
1043             }),
1044             withToString("int[i + 1]", (int s) -> {
1045                 return fill(s * BUFFER_REPS,
1046                             i -> (int)(i + 1));
1047             }),
1048             withToString("int[i - 2]", (int s) -> {
1049                 return fill(s * BUFFER_REPS,
1050                             i -> (int)(i - 2));
1051             }),
1052             withToString("int[zigZag(i)]", (int s) -> {
1053                 return fill(s * BUFFER_REPS,
1054                             i -> i%3 == 0 ? (int)i : (i%3 == 1 ? (int)(i + 1) : (int)(i - 2)));

1155             }
1156         }
1157     }
1158 
1159     static void replaceZero(int[] a, boolean[] mask, int v) {
1160         for (int i = 0; i < a.length; i++) {
1161             if (mask[i % mask.length] && a[i] == 0) {
1162                 a[i] = v;
1163             }
1164         }
1165     }
1166 
1167     static int ROL_scalar(int a, int b) {
1168         return Integer.rotateLeft(a, ((int)b));
1169     }
1170 
1171     static int ROR_scalar(int a, int b) {
1172         return Integer.rotateRight(a, ((int)b));
1173     }
1174 












1175     static boolean eq(int a, int b) {
1176         return a == b;
1177     }
1178 
1179     static boolean neq(int a, int b) {
1180         return a != b;
1181     }
1182 
1183     static boolean lt(int a, int b) {
1184         return a < b;
1185     }
1186 
1187     static boolean le(int a, int b) {
1188         return a <= b;
1189     }
1190 
1191     static boolean gt(int a, int b) {
1192         return a > b;
1193     }
1194 

1309     @Test
1310     // Test div by 0.
1311     static void bitwiseDivByZeroSmokeTest() {
1312         try {
1313             IntVector a = (IntVector) SPECIES.broadcast(0).addIndex(1);
1314             IntVector b = (IntVector) SPECIES.broadcast(0);
1315             a.div(b);
1316             Assert.fail();
1317         } catch (ArithmeticException e) {
1318         }
1319 
1320         try {
1321             IntVector a = (IntVector) SPECIES.broadcast(0).addIndex(1);
1322             IntVector b = (IntVector) SPECIES.broadcast(0);
1323             VectorMask<Integer> m = a.lt((int) 1);
1324             a.div(b, m);
1325             Assert.fail();
1326         } catch (ArithmeticException e) {
1327         }
1328     }

1329     static int ADD(int a, int b) {
1330         return (int)(a + b);
1331     }
1332 
1333     @Test(dataProvider = "intBinaryOpProvider")
1334     static void ADDIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1335         int[] a = fa.apply(SPECIES.length());
1336         int[] b = fb.apply(SPECIES.length());
1337         int[] r = fr.apply(SPECIES.length());
1338 
1339         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1340             for (int i = 0; i < a.length; i += SPECIES.length()) {
1341                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1342                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1343                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1344             }
1345         }
1346 
1347         assertArraysEquals(r, a, b, IntMaxVectorTests::ADD);
1348     }

1349     static int add(int a, int b) {
1350         return (int)(a + b);
1351     }
1352 
1353     @Test(dataProvider = "intBinaryOpProvider")
1354     static void addIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1355         int[] a = fa.apply(SPECIES.length());
1356         int[] b = fb.apply(SPECIES.length());
1357         int[] r = fr.apply(SPECIES.length());
1358 
1359         for (int i = 0; i < a.length; i += SPECIES.length()) {
1360             IntVector av = IntVector.fromArray(SPECIES, a, i);
1361             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1362             av.add(bv).intoArray(r, i);
1363         }
1364 
1365         assertArraysEquals(r, a, b, IntMaxVectorTests::add);
1366     }
1367 
1368     @Test(dataProvider = "intBinaryOpMaskProvider")

1385         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ADD);
1386     }
1387 
1388     @Test(dataProvider = "intBinaryOpMaskProvider")
1389     static void addIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1390                                           IntFunction<boolean[]> fm) {
1391         int[] a = fa.apply(SPECIES.length());
1392         int[] b = fb.apply(SPECIES.length());
1393         int[] r = fr.apply(SPECIES.length());
1394         boolean[] mask = fm.apply(SPECIES.length());
1395         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1396 
1397         for (int i = 0; i < a.length; i += SPECIES.length()) {
1398             IntVector av = IntVector.fromArray(SPECIES, a, i);
1399             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1400             av.add(bv, vmask).intoArray(r, i);
1401         }
1402 
1403         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::add);
1404     }

1405     static int SUB(int a, int b) {
1406         return (int)(a - b);
1407     }
1408 
1409     @Test(dataProvider = "intBinaryOpProvider")
1410     static void SUBIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1411         int[] a = fa.apply(SPECIES.length());
1412         int[] b = fb.apply(SPECIES.length());
1413         int[] r = fr.apply(SPECIES.length());
1414 
1415         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1416             for (int i = 0; i < a.length; i += SPECIES.length()) {
1417                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1418                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1419                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1420             }
1421         }
1422 
1423         assertArraysEquals(r, a, b, IntMaxVectorTests::SUB);
1424     }

1425     static int sub(int a, int b) {
1426         return (int)(a - b);
1427     }
1428 
1429     @Test(dataProvider = "intBinaryOpProvider")
1430     static void subIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1431         int[] a = fa.apply(SPECIES.length());
1432         int[] b = fb.apply(SPECIES.length());
1433         int[] r = fr.apply(SPECIES.length());
1434 
1435         for (int i = 0; i < a.length; i += SPECIES.length()) {
1436             IntVector av = IntVector.fromArray(SPECIES, a, i);
1437             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1438             av.sub(bv).intoArray(r, i);
1439         }
1440 
1441         assertArraysEquals(r, a, b, IntMaxVectorTests::sub);
1442     }
1443 
1444     @Test(dataProvider = "intBinaryOpMaskProvider")

1461         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SUB);
1462     }
1463 
1464     @Test(dataProvider = "intBinaryOpMaskProvider")
1465     static void subIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1466                                           IntFunction<boolean[]> fm) {
1467         int[] a = fa.apply(SPECIES.length());
1468         int[] b = fb.apply(SPECIES.length());
1469         int[] r = fr.apply(SPECIES.length());
1470         boolean[] mask = fm.apply(SPECIES.length());
1471         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1472 
1473         for (int i = 0; i < a.length; i += SPECIES.length()) {
1474             IntVector av = IntVector.fromArray(SPECIES, a, i);
1475             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1476             av.sub(bv, vmask).intoArray(r, i);
1477         }
1478 
1479         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::sub);
1480     }

1481     static int MUL(int a, int b) {
1482         return (int)(a * b);
1483     }
1484 
1485     @Test(dataProvider = "intBinaryOpProvider")
1486     static void MULIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1487         int[] a = fa.apply(SPECIES.length());
1488         int[] b = fb.apply(SPECIES.length());
1489         int[] r = fr.apply(SPECIES.length());
1490 
1491         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1492             for (int i = 0; i < a.length; i += SPECIES.length()) {
1493                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1494                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1495                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1496             }
1497         }
1498 
1499         assertArraysEquals(r, a, b, IntMaxVectorTests::MUL);
1500     }

1501     static int mul(int a, int b) {
1502         return (int)(a * b);
1503     }
1504 
1505     @Test(dataProvider = "intBinaryOpProvider")
1506     static void mulIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1507         int[] a = fa.apply(SPECIES.length());
1508         int[] b = fb.apply(SPECIES.length());
1509         int[] r = fr.apply(SPECIES.length());
1510 
1511         for (int i = 0; i < a.length; i += SPECIES.length()) {
1512             IntVector av = IntVector.fromArray(SPECIES, a, i);
1513             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1514             av.mul(bv).intoArray(r, i);
1515         }
1516 
1517         assertArraysEquals(r, a, b, IntMaxVectorTests::mul);
1518     }
1519 
1520     @Test(dataProvider = "intBinaryOpMaskProvider")

1538     }
1539 
1540     @Test(dataProvider = "intBinaryOpMaskProvider")
1541     static void mulIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1542                                           IntFunction<boolean[]> fm) {
1543         int[] a = fa.apply(SPECIES.length());
1544         int[] b = fb.apply(SPECIES.length());
1545         int[] r = fr.apply(SPECIES.length());
1546         boolean[] mask = fm.apply(SPECIES.length());
1547         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1548 
1549         for (int i = 0; i < a.length; i += SPECIES.length()) {
1550             IntVector av = IntVector.fromArray(SPECIES, a, i);
1551             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1552             av.mul(bv, vmask).intoArray(r, i);
1553         }
1554 
1555         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::mul);
1556     }
1557 
1558 
1559 
1560     static int DIV(int a, int b) {
1561         return (int)(a / b);
1562     }
1563 
1564     @Test(dataProvider = "intBinaryOpProvider")
1565     static void DIVIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1566         int[] a = fa.apply(SPECIES.length());
1567         int[] b = fb.apply(SPECIES.length());
1568         int[] r = fr.apply(SPECIES.length());
1569 
1570         replaceZero(b, (int) 1);
1571 
1572         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1573             for (int i = 0; i < a.length; i += SPECIES.length()) {
1574                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1575                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1576                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1577             }
1578         }
1579 
1580         assertArraysEquals(r, a, b, IntMaxVectorTests::DIV);
1581     }

1582     static int div(int a, int b) {
1583         return (int)(a / b);
1584     }
1585 
1586     @Test(dataProvider = "intBinaryOpProvider")
1587     static void divIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1588         int[] a = fa.apply(SPECIES.length());
1589         int[] b = fb.apply(SPECIES.length());
1590         int[] r = fr.apply(SPECIES.length());
1591 
1592         replaceZero(b, (int) 1);
1593 
1594         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1595             for (int i = 0; i < a.length; i += SPECIES.length()) {
1596                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1597                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1598                 av.div(bv).intoArray(r, i);
1599             }
1600         }
1601 
1602         assertArraysEquals(r, a, b, IntMaxVectorTests::div);
1603     }
1604 
1605 
1606 
1607     @Test(dataProvider = "intBinaryOpMaskProvider")
1608     static void DIVIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1609                                           IntFunction<boolean[]> fm) {
1610         int[] a = fa.apply(SPECIES.length());
1611         int[] b = fb.apply(SPECIES.length());
1612         int[] r = fr.apply(SPECIES.length());
1613         boolean[] mask = fm.apply(SPECIES.length());
1614         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1615 
1616         replaceZero(b, mask, (int) 1);
1617 
1618         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1619             for (int i = 0; i < a.length; i += SPECIES.length()) {
1620                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1621                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1622                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1623             }
1624         }
1625 
1626         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::DIV);

1692     static int AND(int a, int b) {
1693         return (int)(a & b);
1694     }
1695 
1696     @Test(dataProvider = "intBinaryOpProvider")
1697     static void ANDIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1698         int[] a = fa.apply(SPECIES.length());
1699         int[] b = fb.apply(SPECIES.length());
1700         int[] r = fr.apply(SPECIES.length());
1701 
1702         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1703             for (int i = 0; i < a.length; i += SPECIES.length()) {
1704                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1705                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1706                 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1707             }
1708         }
1709 
1710         assertArraysEquals(r, a, b, IntMaxVectorTests::AND);
1711     }

1712     static int and(int a, int b) {
1713         return (int)(a & b);
1714     }
1715 
1716     @Test(dataProvider = "intBinaryOpProvider")
1717     static void andIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1718         int[] a = fa.apply(SPECIES.length());
1719         int[] b = fb.apply(SPECIES.length());
1720         int[] r = fr.apply(SPECIES.length());
1721 
1722         for (int i = 0; i < a.length; i += SPECIES.length()) {
1723             IntVector av = IntVector.fromArray(SPECIES, a, i);
1724             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1725             av.and(bv).intoArray(r, i);
1726         }
1727 
1728         assertArraysEquals(r, a, b, IntMaxVectorTests::and);
1729     }
1730 
1731 
1732 
1733     @Test(dataProvider = "intBinaryOpMaskProvider")
1734     static void ANDIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1735                                           IntFunction<boolean[]> fm) {
1736         int[] a = fa.apply(SPECIES.length());
1737         int[] b = fb.apply(SPECIES.length());
1738         int[] r = fr.apply(SPECIES.length());
1739         boolean[] mask = fm.apply(SPECIES.length());
1740         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1741 
1742         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1743             for (int i = 0; i < a.length; i += SPECIES.length()) {
1744                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1745                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1746                 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
1747             }
1748         }
1749 
1750         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::AND);
1751     }
1752 
1753 
1754     static int AND_NOT(int a, int b) {
1755         return (int)(a & ~b);
1756     }
1757 
1758     @Test(dataProvider = "intBinaryOpProvider")
1759     static void AND_NOTIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1760         int[] a = fa.apply(SPECIES.length());
1761         int[] b = fb.apply(SPECIES.length());
1762         int[] r = fr.apply(SPECIES.length());
1763 
1764         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1765             for (int i = 0; i < a.length; i += SPECIES.length()) {
1766                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1767                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1768                 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
1769             }
1770         }
1771 
1772         assertArraysEquals(r, a, b, IntMaxVectorTests::AND_NOT);
1773     }
1774 
1775 
1776 
1777     @Test(dataProvider = "intBinaryOpMaskProvider")
1778     static void AND_NOTIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1779                                           IntFunction<boolean[]> fm) {
1780         int[] a = fa.apply(SPECIES.length());
1781         int[] b = fb.apply(SPECIES.length());
1782         int[] r = fr.apply(SPECIES.length());
1783         boolean[] mask = fm.apply(SPECIES.length());
1784         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1785 
1786         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1787             for (int i = 0; i < a.length; i += SPECIES.length()) {
1788                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1789                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1790                 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
1791             }
1792         }
1793 
1794         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::AND_NOT);
1795     }
1796 
1797 
1798     static int OR(int a, int b) {
1799         return (int)(a | b);
1800     }
1801 
1802     @Test(dataProvider = "intBinaryOpProvider")
1803     static void ORIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1804         int[] a = fa.apply(SPECIES.length());
1805         int[] b = fb.apply(SPECIES.length());
1806         int[] r = fr.apply(SPECIES.length());
1807 
1808         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1809             for (int i = 0; i < a.length; i += SPECIES.length()) {
1810                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1811                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1812                 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1813             }
1814         }
1815 
1816         assertArraysEquals(r, a, b, IntMaxVectorTests::OR);
1817     }

1818     static int or(int a, int b) {
1819         return (int)(a | b);
1820     }
1821 
1822     @Test(dataProvider = "intBinaryOpProvider")
1823     static void orIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1824         int[] a = fa.apply(SPECIES.length());
1825         int[] b = fb.apply(SPECIES.length());
1826         int[] r = fr.apply(SPECIES.length());
1827 
1828         for (int i = 0; i < a.length; i += SPECIES.length()) {
1829             IntVector av = IntVector.fromArray(SPECIES, a, i);
1830             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1831             av.or(bv).intoArray(r, i);
1832         }
1833 
1834         assertArraysEquals(r, a, b, IntMaxVectorTests::or);
1835     }
1836 
1837 
1838 
1839     @Test(dataProvider = "intBinaryOpMaskProvider")
1840     static void ORIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1841                                           IntFunction<boolean[]> fm) {
1842         int[] a = fa.apply(SPECIES.length());
1843         int[] b = fb.apply(SPECIES.length());
1844         int[] r = fr.apply(SPECIES.length());
1845         boolean[] mask = fm.apply(SPECIES.length());
1846         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1847 
1848         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1849             for (int i = 0; i < a.length; i += SPECIES.length()) {
1850                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1851                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1852                 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1853             }
1854         }
1855 
1856         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::OR);
1857     }
1858 
1859 
1860     static int XOR(int a, int b) {
1861         return (int)(a ^ b);
1862     }
1863 
1864     @Test(dataProvider = "intBinaryOpProvider")
1865     static void XORIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1866         int[] a = fa.apply(SPECIES.length());
1867         int[] b = fb.apply(SPECIES.length());
1868         int[] r = fr.apply(SPECIES.length());
1869 
1870         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1871             for (int i = 0; i < a.length; i += SPECIES.length()) {
1872                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1873                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1874                 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
1875             }
1876         }
1877 
1878         assertArraysEquals(r, a, b, IntMaxVectorTests::XOR);
1879     }
1880 
1881 
1882 
1883     @Test(dataProvider = "intBinaryOpMaskProvider")
1884     static void XORIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1885                                           IntFunction<boolean[]> fm) {
1886         int[] a = fa.apply(SPECIES.length());
1887         int[] b = fb.apply(SPECIES.length());
1888         int[] r = fr.apply(SPECIES.length());
1889         boolean[] mask = fm.apply(SPECIES.length());
1890         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1891 
1892         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1893             for (int i = 0; i < a.length; i += SPECIES.length()) {
1894                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1895                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1896                 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1897             }
1898         }
1899 
1900         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::XOR);
1901     }
1902 

















































































1903 
1904     @Test(dataProvider = "intBinaryOpProvider")
1905     static void addIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1906         int[] a = fa.apply(SPECIES.length());
1907         int[] b = fb.apply(SPECIES.length());
1908         int[] r = fr.apply(SPECIES.length());
1909 
1910         for (int i = 0; i < a.length; i += SPECIES.length()) {
1911             IntVector av = IntVector.fromArray(SPECIES, a, i);
1912             av.add(b[i]).intoArray(r, i);
1913         }
1914 
1915         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::add);
1916     }
1917 
1918     @Test(dataProvider = "intBinaryOpMaskProvider")
1919     static void addIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
1920                                           IntFunction<boolean[]> fm) {
1921         int[] a = fa.apply(SPECIES.length());
1922         int[] b = fb.apply(SPECIES.length());

1977         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::mul);
1978     }
1979 
1980     @Test(dataProvider = "intBinaryOpMaskProvider")
1981     static void mulIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
1982                                           IntFunction<boolean[]> fm) {
1983         int[] a = fa.apply(SPECIES.length());
1984         int[] b = fb.apply(SPECIES.length());
1985         int[] r = fr.apply(SPECIES.length());
1986         boolean[] mask = fm.apply(SPECIES.length());
1987         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1988 
1989         for (int i = 0; i < a.length; i += SPECIES.length()) {
1990             IntVector av = IntVector.fromArray(SPECIES, a, i);
1991             av.mul(b[i], vmask).intoArray(r, i);
1992         }
1993 
1994         assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::mul);
1995     }
1996 
1997 
1998 
1999 
2000     @Test(dataProvider = "intBinaryOpProvider")
2001     static void divIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2002         int[] a = fa.apply(SPECIES.length());
2003         int[] b = fb.apply(SPECIES.length());
2004         int[] r = fr.apply(SPECIES.length());
2005 
2006         replaceZero(b, (int) 1);
2007 
2008         for (int i = 0; i < a.length; i += SPECIES.length()) {
2009             IntVector av = IntVector.fromArray(SPECIES, a, i);
2010             av.div(b[i]).intoArray(r, i);
2011         }
2012 
2013         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::div);
2014     }
2015 
2016 
2017 
2018     @Test(dataProvider = "intBinaryOpMaskProvider")
2019     static void divIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2020                                           IntFunction<boolean[]> fm) {
2021         int[] a = fa.apply(SPECIES.length());
2022         int[] b = fb.apply(SPECIES.length());
2023         int[] r = fr.apply(SPECIES.length());
2024         boolean[] mask = fm.apply(SPECIES.length());
2025         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2026 
2027         replaceZero(b, (int) 1);
2028 
2029         for (int i = 0; i < a.length; i += SPECIES.length()) {
2030             IntVector av = IntVector.fromArray(SPECIES, a, i);
2031             av.div(b[i], vmask).intoArray(r, i);
2032         }
2033 
2034         assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::div);
2035     }
2036 
2037 
2038 
2039     @Test(dataProvider = "intBinaryOpProvider")
2040     static void ORIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2041         int[] a = fa.apply(SPECIES.length());
2042         int[] b = fb.apply(SPECIES.length());
2043         int[] r = fr.apply(SPECIES.length());
2044 
2045         for (int i = 0; i < a.length; i += SPECIES.length()) {
2046             IntVector av = IntVector.fromArray(SPECIES, a, i);
2047             av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2048         }
2049 
2050         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::OR);
2051     }
2052 
2053     @Test(dataProvider = "intBinaryOpProvider")
2054     static void orIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2055         int[] a = fa.apply(SPECIES.length());
2056         int[] b = fb.apply(SPECIES.length());
2057         int[] r = fr.apply(SPECIES.length());
2058 
2059         for (int i = 0; i < a.length; i += SPECIES.length()) {
2060             IntVector av = IntVector.fromArray(SPECIES, a, i);
2061             av.or(b[i]).intoArray(r, i);
2062         }
2063 
2064         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::or);
2065     }
2066 
2067 
2068 
2069     @Test(dataProvider = "intBinaryOpMaskProvider")
2070     static void ORIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2071                                           IntFunction<boolean[]> fm) {
2072         int[] a = fa.apply(SPECIES.length());
2073         int[] b = fb.apply(SPECIES.length());
2074         int[] r = fr.apply(SPECIES.length());
2075         boolean[] mask = fm.apply(SPECIES.length());
2076         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2077 
2078         for (int i = 0; i < a.length; i += SPECIES.length()) {
2079             IntVector av = IntVector.fromArray(SPECIES, a, i);
2080             av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2081         }
2082 
2083         assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::OR);
2084     }
2085 
2086 
2087 
2088     @Test(dataProvider = "intBinaryOpProvider")
2089     static void ANDIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2090         int[] a = fa.apply(SPECIES.length());
2091         int[] b = fb.apply(SPECIES.length());
2092         int[] r = fr.apply(SPECIES.length());
2093 
2094         for (int i = 0; i < a.length; i += SPECIES.length()) {
2095             IntVector av = IntVector.fromArray(SPECIES, a, i);
2096             av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2097         }
2098 
2099         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::AND);
2100     }
2101 
2102     @Test(dataProvider = "intBinaryOpProvider")
2103     static void andIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2104         int[] a = fa.apply(SPECIES.length());
2105         int[] b = fb.apply(SPECIES.length());
2106         int[] r = fr.apply(SPECIES.length());
2107 
2108         for (int i = 0; i < a.length; i += SPECIES.length()) {
2109             IntVector av = IntVector.fromArray(SPECIES, a, i);
2110             av.and(b[i]).intoArray(r, i);
2111         }
2112 
2113         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::and);
2114     }
2115 
2116 
2117 
2118     @Test(dataProvider = "intBinaryOpMaskProvider")
2119     static void ANDIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2120                                           IntFunction<boolean[]> fm) {
2121         int[] a = fa.apply(SPECIES.length());
2122         int[] b = fb.apply(SPECIES.length());
2123         int[] r = fr.apply(SPECIES.length());
2124         boolean[] mask = fm.apply(SPECIES.length());
2125         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2126 
2127         for (int i = 0; i < a.length; i += SPECIES.length()) {
2128             IntVector av = IntVector.fromArray(SPECIES, a, i);
2129             av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2130         }
2131 
2132         assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::AND);
2133     }
2134 
2135 
2136 
2137     @Test(dataProvider = "intBinaryOpProvider")
2138     static void ORIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2139         int[] a = fa.apply(SPECIES.length());
2140         int[] b = fb.apply(SPECIES.length());
2141         int[] r = fr.apply(SPECIES.length());
2142 
2143         for (int i = 0; i < a.length; i += SPECIES.length()) {
2144             IntVector av = IntVector.fromArray(SPECIES, a, i);
2145             av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2146         }
2147 
2148         assertBroadcastLongArraysEquals(r, a, b, IntMaxVectorTests::OR);
2149     }
2150 
2151 
2152 
2153     @Test(dataProvider = "intBinaryOpMaskProvider")
2154     static void ORIntMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2155                                           IntFunction<boolean[]> fm) {
2156         int[] a = fa.apply(SPECIES.length());
2157         int[] b = fb.apply(SPECIES.length());
2158         int[] r = fr.apply(SPECIES.length());
2159         boolean[] mask = fm.apply(SPECIES.length());
2160         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2161 
2162         for (int i = 0; i < a.length; i += SPECIES.length()) {
2163             IntVector av = IntVector.fromArray(SPECIES, a, i);
2164             av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2165         }
2166 
2167         assertBroadcastLongArraysEquals(r, a, b, mask, IntMaxVectorTests::OR);
2168     }
2169 
2170 
2171     @Test(dataProvider = "intBinaryOpProvider")
2172     static void ADDIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2173         int[] a = fa.apply(SPECIES.length());
2174         int[] b = fb.apply(SPECIES.length());
2175         int[] r = fr.apply(SPECIES.length());
2176 
2177         for (int i = 0; i < a.length; i += SPECIES.length()) {
2178             IntVector av = IntVector.fromArray(SPECIES, a, i);
2179             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2180         }
2181 
2182         assertBroadcastLongArraysEquals(r, a, b, IntMaxVectorTests::ADD);
2183     }
2184 
2185     @Test(dataProvider = "intBinaryOpMaskProvider")
2186     static void ADDIntMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2187                                           IntFunction<boolean[]> fm) {
2188         int[] a = fa.apply(SPECIES.length());
2189         int[] b = fb.apply(SPECIES.length());
2190         int[] r = fr.apply(SPECIES.length());

2203         return (int)((a << b));
2204     }
2205 
2206     @Test(dataProvider = "intBinaryOpProvider")
2207     static void LSHLIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2208         int[] a = fa.apply(SPECIES.length());
2209         int[] b = fb.apply(SPECIES.length());
2210         int[] r = fr.apply(SPECIES.length());
2211 
2212         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2213             for (int i = 0; i < a.length; i += SPECIES.length()) {
2214                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2215                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2216                 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2217             }
2218         }
2219 
2220         assertArraysEquals(r, a, b, IntMaxVectorTests::LSHL);
2221     }
2222 
2223 
2224 
2225     @Test(dataProvider = "intBinaryOpMaskProvider")
2226     static void LSHLIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2227                                           IntFunction<boolean[]> fm) {
2228         int[] a = fa.apply(SPECIES.length());
2229         int[] b = fb.apply(SPECIES.length());
2230         int[] r = fr.apply(SPECIES.length());
2231         boolean[] mask = fm.apply(SPECIES.length());
2232         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2233 
2234         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2235             for (int i = 0; i < a.length; i += SPECIES.length()) {
2236                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2237                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2238                 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2239             }
2240         }
2241 
2242         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHL);
2243     }
2244 
2245 
2246 
2247 
2248 
2249 
2250     static int ASHR(int a, int b) {
2251         return (int)((a >> b));
2252     }
2253 
2254     @Test(dataProvider = "intBinaryOpProvider")
2255     static void ASHRIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2256         int[] a = fa.apply(SPECIES.length());
2257         int[] b = fb.apply(SPECIES.length());
2258         int[] r = fr.apply(SPECIES.length());
2259 
2260         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2261             for (int i = 0; i < a.length; i += SPECIES.length()) {
2262                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2263                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2264                 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2265             }
2266         }
2267 
2268         assertArraysEquals(r, a, b, IntMaxVectorTests::ASHR);
2269     }
2270 
2271 
2272 
2273     @Test(dataProvider = "intBinaryOpMaskProvider")
2274     static void ASHRIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2275                                           IntFunction<boolean[]> fm) {
2276         int[] a = fa.apply(SPECIES.length());
2277         int[] b = fb.apply(SPECIES.length());
2278         int[] r = fr.apply(SPECIES.length());
2279         boolean[] mask = fm.apply(SPECIES.length());
2280         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2281 
2282         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2283             for (int i = 0; i < a.length; i += SPECIES.length()) {
2284                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2285                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2286                 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2287             }
2288         }
2289 
2290         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ASHR);
2291     }
2292 
2293 
2294 
2295 
2296 
2297 
2298     static int LSHR(int a, int b) {
2299         return (int)((a >>> b));
2300     }
2301 
2302     @Test(dataProvider = "intBinaryOpProvider")
2303     static void LSHRIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2304         int[] a = fa.apply(SPECIES.length());
2305         int[] b = fb.apply(SPECIES.length());
2306         int[] r = fr.apply(SPECIES.length());
2307 
2308         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2309             for (int i = 0; i < a.length; i += SPECIES.length()) {
2310                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2311                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2312                 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2313             }
2314         }
2315 
2316         assertArraysEquals(r, a, b, IntMaxVectorTests::LSHR);
2317     }
2318 
2319 
2320 
2321     @Test(dataProvider = "intBinaryOpMaskProvider")
2322     static void LSHRIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2323                                           IntFunction<boolean[]> fm) {
2324         int[] a = fa.apply(SPECIES.length());
2325         int[] b = fb.apply(SPECIES.length());
2326         int[] r = fr.apply(SPECIES.length());
2327         boolean[] mask = fm.apply(SPECIES.length());
2328         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2329 
2330         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2331             for (int i = 0; i < a.length; i += SPECIES.length()) {
2332                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2333                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2334                 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2335             }
2336         }
2337 
2338         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHR);
2339     }
2340 
2341 
2342 
2343 
2344 
2345 
2346     static int LSHL_unary(int a, int b) {
2347         return (int)((a << b));
2348     }
2349 
2350     @Test(dataProvider = "intBinaryOpProvider")
2351     static void LSHLIntMaxVectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2352         int[] a = fa.apply(SPECIES.length());
2353         int[] b = fb.apply(SPECIES.length());
2354         int[] r = fr.apply(SPECIES.length());
2355 
2356         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2357             for (int i = 0; i < a.length; i += SPECIES.length()) {
2358                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2359                 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2360             }
2361         }
2362 
2363         assertShiftArraysEquals(r, a, b, IntMaxVectorTests::LSHL_unary);
2364     }
2365 
2366 
2367 
2368     @Test(dataProvider = "intBinaryOpMaskProvider")
2369     static void LSHLIntMaxVectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2370                                           IntFunction<boolean[]> fm) {
2371         int[] a = fa.apply(SPECIES.length());
2372         int[] b = fb.apply(SPECIES.length());
2373         int[] r = fr.apply(SPECIES.length());
2374         boolean[] mask = fm.apply(SPECIES.length());
2375         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2376 
2377         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2378             for (int i = 0; i < a.length; i += SPECIES.length()) {
2379                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2380                 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2381             }
2382         }
2383 
2384         assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHL_unary);
2385     }
2386 
2387 
2388 
2389 
2390 
2391 
2392     static int LSHR_unary(int a, int b) {
2393         return (int)((a >>> b));
2394     }
2395 
2396     @Test(dataProvider = "intBinaryOpProvider")
2397     static void LSHRIntMaxVectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2398         int[] a = fa.apply(SPECIES.length());
2399         int[] b = fb.apply(SPECIES.length());
2400         int[] r = fr.apply(SPECIES.length());
2401 
2402         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2403             for (int i = 0; i < a.length; i += SPECIES.length()) {
2404                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2405                 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2406             }
2407         }
2408 
2409         assertShiftArraysEquals(r, a, b, IntMaxVectorTests::LSHR_unary);
2410     }
2411 
2412 
2413 
2414     @Test(dataProvider = "intBinaryOpMaskProvider")
2415     static void LSHRIntMaxVectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2416                                           IntFunction<boolean[]> fm) {
2417         int[] a = fa.apply(SPECIES.length());
2418         int[] b = fb.apply(SPECIES.length());
2419         int[] r = fr.apply(SPECIES.length());
2420         boolean[] mask = fm.apply(SPECIES.length());
2421         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2422 
2423         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2424             for (int i = 0; i < a.length; i += SPECIES.length()) {
2425                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2426                 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2427             }
2428         }
2429 
2430         assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHR_unary);
2431     }
2432 
2433 
2434 
2435 
2436 
2437 
2438     static int ASHR_unary(int a, int b) {
2439         return (int)((a >> b));
2440     }
2441 
2442     @Test(dataProvider = "intBinaryOpProvider")
2443     static void ASHRIntMaxVectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2444         int[] a = fa.apply(SPECIES.length());
2445         int[] b = fb.apply(SPECIES.length());
2446         int[] r = fr.apply(SPECIES.length());
2447 
2448         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2449             for (int i = 0; i < a.length; i += SPECIES.length()) {
2450                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2451                 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2452             }
2453         }
2454 
2455         assertShiftArraysEquals(r, a, b, IntMaxVectorTests::ASHR_unary);
2456     }
2457 
2458 
2459 
2460     @Test(dataProvider = "intBinaryOpMaskProvider")
2461     static void ASHRIntMaxVectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2462                                           IntFunction<boolean[]> fm) {
2463         int[] a = fa.apply(SPECIES.length());
2464         int[] b = fb.apply(SPECIES.length());
2465         int[] r = fr.apply(SPECIES.length());
2466         boolean[] mask = fm.apply(SPECIES.length());
2467         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2468 
2469         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2470             for (int i = 0; i < a.length; i += SPECIES.length()) {
2471                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2472                 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2473             }
2474         }
2475 
2476         assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::ASHR_unary);
2477     }
2478 
2479 
2480 
2481 
2482 
2483 
2484     static int ROR(int a, int b) {
2485         return (int)(ROR_scalar(a,b));
2486     }
2487 
2488     @Test(dataProvider = "intBinaryOpProvider")
2489     static void RORIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2490         int[] a = fa.apply(SPECIES.length());
2491         int[] b = fb.apply(SPECIES.length());
2492         int[] r = fr.apply(SPECIES.length());
2493 
2494         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2495             for (int i = 0; i < a.length; i += SPECIES.length()) {
2496                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2497                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2498                 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2499             }
2500         }
2501 
2502         assertArraysEquals(r, a, b, IntMaxVectorTests::ROR);
2503     }
2504 
2505 
2506 
2507     @Test(dataProvider = "intBinaryOpMaskProvider")
2508     static void RORIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2509                                           IntFunction<boolean[]> fm) {
2510         int[] a = fa.apply(SPECIES.length());
2511         int[] b = fb.apply(SPECIES.length());
2512         int[] r = fr.apply(SPECIES.length());
2513         boolean[] mask = fm.apply(SPECIES.length());
2514         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2515 
2516         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2517             for (int i = 0; i < a.length; i += SPECIES.length()) {
2518                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2519                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2520                 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2521             }
2522         }
2523 
2524         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ROR);
2525     }
2526 
2527 
2528     static int ROL(int a, int b) {
2529         return (int)(ROL_scalar(a,b));
2530     }
2531 
2532     @Test(dataProvider = "intBinaryOpProvider")
2533     static void ROLIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2534         int[] a = fa.apply(SPECIES.length());
2535         int[] b = fb.apply(SPECIES.length());
2536         int[] r = fr.apply(SPECIES.length());
2537 
2538         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2539             for (int i = 0; i < a.length; i += SPECIES.length()) {
2540                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2541                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2542                 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2543             }
2544         }
2545 
2546         assertArraysEquals(r, a, b, IntMaxVectorTests::ROL);
2547     }
2548 
2549 
2550 
2551     @Test(dataProvider = "intBinaryOpMaskProvider")
2552     static void ROLIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2553                                           IntFunction<boolean[]> fm) {
2554         int[] a = fa.apply(SPECIES.length());
2555         int[] b = fb.apply(SPECIES.length());
2556         int[] r = fr.apply(SPECIES.length());
2557         boolean[] mask = fm.apply(SPECIES.length());
2558         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2559 
2560         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2561             for (int i = 0; i < a.length; i += SPECIES.length()) {
2562                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2563                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2564                 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2565             }
2566         }
2567 
2568         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ROL);
2569     }
2570 
2571 
2572     static int ROR_unary(int a, int b) {
2573         return (int)(ROR_scalar(a, b));
2574     }
2575 
2576     @Test(dataProvider = "intBinaryOpProvider")
2577     static void RORIntMaxVectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2578         int[] a = fa.apply(SPECIES.length());
2579         int[] b = fb.apply(SPECIES.length());
2580         int[] r = fr.apply(SPECIES.length());
2581 
2582         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2583             for (int i = 0; i < a.length; i += SPECIES.length()) {
2584                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2585                 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2586             }
2587         }
2588 
2589         assertShiftArraysEquals(r, a, b, IntMaxVectorTests::ROR_unary);
2590     }
2591 
2592 
2593 
2594     @Test(dataProvider = "intBinaryOpMaskProvider")
2595     static void RORIntMaxVectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2596                                           IntFunction<boolean[]> fm) {
2597         int[] a = fa.apply(SPECIES.length());
2598         int[] b = fb.apply(SPECIES.length());
2599         int[] r = fr.apply(SPECIES.length());
2600         boolean[] mask = fm.apply(SPECIES.length());
2601         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2602 
2603         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2604             for (int i = 0; i < a.length; i += SPECIES.length()) {
2605                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2606                 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2607             }
2608         }
2609 
2610         assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::ROR_unary);
2611     }
2612 
2613 
2614     static int ROL_unary(int a, int b) {
2615         return (int)(ROL_scalar(a, b));
2616     }
2617 
2618     @Test(dataProvider = "intBinaryOpProvider")
2619     static void ROLIntMaxVectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2620         int[] a = fa.apply(SPECIES.length());
2621         int[] b = fb.apply(SPECIES.length());
2622         int[] r = fr.apply(SPECIES.length());
2623 
2624         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2625             for (int i = 0; i < a.length; i += SPECIES.length()) {
2626                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2627                 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2628             }
2629         }
2630 
2631         assertShiftArraysEquals(r, a, b, IntMaxVectorTests::ROL_unary);
2632     }
2633 
2634 
2635 
2636     @Test(dataProvider = "intBinaryOpMaskProvider")
2637     static void ROLIntMaxVectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2638                                           IntFunction<boolean[]> fm) {
2639         int[] a = fa.apply(SPECIES.length());
2640         int[] b = fb.apply(SPECIES.length());
2641         int[] r = fr.apply(SPECIES.length());
2642         boolean[] mask = fm.apply(SPECIES.length());
2643         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2644 
2645         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2646             for (int i = 0; i < a.length; i += SPECIES.length()) {
2647                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2648                 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2649             }
2650         }
2651 
2652         assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::ROL_unary);
2653     }
2654 
2655 
2656     static int LSHR_binary_const(int a) {
2657         return (int)((a >>> CONST_SHIFT));
2658     }
2659 
2660     @Test(dataProvider = "intUnaryOpProvider")
2661     static void LSHRIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
2662         int[] a = fa.apply(SPECIES.length());
2663         int[] r = fr.apply(SPECIES.length());
2664 
2665         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2666             for (int i = 0; i < a.length; i += SPECIES.length()) {
2667                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2668                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
2669             }
2670         }
2671 
2672         assertShiftConstEquals(r, a, IntMaxVectorTests::LSHR_binary_const);
2673     }
2674 
2675 
2676 
2677     @Test(dataProvider = "intUnaryOpMaskProvider")
2678     static void LSHRIntMaxVectorTestsScalarShiftMaskedConst(IntFunction<int[]> fa,
2679                                           IntFunction<boolean[]> fm) {
2680         int[] a = fa.apply(SPECIES.length());
2681         int[] r = fr.apply(SPECIES.length());
2682         boolean[] mask = fm.apply(SPECIES.length());
2683         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2684 
2685         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2686             for (int i = 0; i < a.length; i += SPECIES.length()) {
2687                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2688                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
2689             }
2690         }
2691 
2692         assertShiftConstEquals(r, a, mask, IntMaxVectorTests::LSHR_binary_const);
2693     }
2694 
2695 
2696 
2697 
2698 
2699 
2700 
2701     static int LSHL_binary_const(int a) {
2702         return (int)((a << CONST_SHIFT));
2703     }
2704 
2705     @Test(dataProvider = "intUnaryOpProvider")
2706     static void LSHLIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
2707         int[] a = fa.apply(SPECIES.length());
2708         int[] r = fr.apply(SPECIES.length());
2709 
2710         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2711             for (int i = 0; i < a.length; i += SPECIES.length()) {
2712                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2713                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
2714             }
2715         }
2716 
2717         assertShiftConstEquals(r, a, IntMaxVectorTests::LSHL_binary_const);
2718     }
2719 
2720 
2721 
2722     @Test(dataProvider = "intUnaryOpMaskProvider")
2723     static void LSHLIntMaxVectorTestsScalarShiftMaskedConst(IntFunction<int[]> fa,
2724                                           IntFunction<boolean[]> fm) {
2725         int[] a = fa.apply(SPECIES.length());
2726         int[] r = fr.apply(SPECIES.length());
2727         boolean[] mask = fm.apply(SPECIES.length());
2728         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2729 
2730         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2731             for (int i = 0; i < a.length; i += SPECIES.length()) {
2732                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2733                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
2734             }
2735         }
2736 
2737         assertShiftConstEquals(r, a, mask, IntMaxVectorTests::LSHL_binary_const);
2738     }
2739 
2740 
2741 
2742     static int ASHR_binary_const(int a) {
2743         return (int)((a >> CONST_SHIFT));
2744     }
2745 
2746     @Test(dataProvider = "intUnaryOpProvider")
2747     static void ASHRIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
2748         int[] a = fa.apply(SPECIES.length());
2749         int[] r = fr.apply(SPECIES.length());
2750 
2751         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2752             for (int i = 0; i < a.length; i += SPECIES.length()) {
2753                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2754                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
2755             }
2756         }
2757 
2758         assertShiftConstEquals(r, a, IntMaxVectorTests::ASHR_binary_const);
2759     }
2760 
2761 
2762 
2763     @Test(dataProvider = "intUnaryOpMaskProvider")
2764     static void ASHRIntMaxVectorTestsScalarShiftMaskedConst(IntFunction<int[]> fa,
2765                                           IntFunction<boolean[]> fm) {
2766         int[] a = fa.apply(SPECIES.length());
2767         int[] r = fr.apply(SPECIES.length());
2768         boolean[] mask = fm.apply(SPECIES.length());
2769         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2770 
2771         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2772             for (int i = 0; i < a.length; i += SPECIES.length()) {
2773                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2774                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
2775             }
2776         }
2777 
2778         assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ASHR_binary_const);
2779     }
2780 
2781 
2782 
2783     static int ROR_binary_const(int a) {
2784         return (int)(ROR_scalar(a, CONST_SHIFT));
2785     }
2786 
2787     @Test(dataProvider = "intUnaryOpProvider")
2788     static void RORIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
2789         int[] a = fa.apply(SPECIES.length());
2790         int[] r = fr.apply(SPECIES.length());
2791 
2792         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2793             for (int i = 0; i < a.length; i += SPECIES.length()) {
2794                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2795                 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
2796             }
2797         }
2798 
2799         assertShiftConstEquals(r, a, IntMaxVectorTests::ROR_binary_const);
2800     }
2801 
2802 
2803 
2804     @Test(dataProvider = "intUnaryOpMaskProvider")
2805     static void RORIntMaxVectorTestsScalarShiftMaskedConst(IntFunction<int[]> fa,
2806                                           IntFunction<boolean[]> fm) {
2807         int[] a = fa.apply(SPECIES.length());
2808         int[] r = fr.apply(SPECIES.length());
2809         boolean[] mask = fm.apply(SPECIES.length());
2810         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2811 
2812         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2813             for (int i = 0; i < a.length; i += SPECIES.length()) {
2814                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2815                 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
2816             }
2817         }
2818 
2819         assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ROR_binary_const);
2820     }
2821 
2822 
2823 
2824     static int ROL_binary_const(int a) {
2825         return (int)(ROL_scalar(a, CONST_SHIFT));
2826     }
2827 
2828     @Test(dataProvider = "intUnaryOpProvider")
2829     static void ROLIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
2830         int[] a = fa.apply(SPECIES.length());
2831         int[] r = fr.apply(SPECIES.length());
2832 
2833         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2834             for (int i = 0; i < a.length; i += SPECIES.length()) {
2835                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2836                 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
2837             }
2838         }
2839 
2840         assertShiftConstEquals(r, a, IntMaxVectorTests::ROL_binary_const);
2841     }
2842 
2843 
2844 
2845     @Test(dataProvider = "intUnaryOpMaskProvider")
2846     static void ROLIntMaxVectorTestsScalarShiftMaskedConst(IntFunction<int[]> fa,
2847                                           IntFunction<boolean[]> fm) {
2848         int[] a = fa.apply(SPECIES.length());
2849         int[] r = fr.apply(SPECIES.length());
2850         boolean[] mask = fm.apply(SPECIES.length());
2851         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2852 
2853         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2854             for (int i = 0; i < a.length; i += SPECIES.length()) {
2855                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2856                 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
2857             }
2858         }
2859 
2860         assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ROL_binary_const);
2861     }
2862 
2863 
2864     static int MIN(int a, int b) {
2865         return (int)(Math.min(a, b));
2866     }
2867 
2868     @Test(dataProvider = "intBinaryOpProvider")
2869     static void MINIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2870         int[] a = fa.apply(SPECIES.length());
2871         int[] b = fb.apply(SPECIES.length());
2872         int[] r = fr.apply(SPECIES.length());
2873 
2874         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2875             for (int i = 0; i < a.length; i += SPECIES.length()) {
2876                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2877                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2878                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2879             }
2880         }
2881 
2882         assertArraysEquals(r, a, b, IntMaxVectorTests::MIN);
2883     }

2884     static int min(int a, int b) {
2885         return (int)(Math.min(a, b));
2886     }
2887 
2888     @Test(dataProvider = "intBinaryOpProvider")
2889     static void minIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2890         int[] a = fa.apply(SPECIES.length());
2891         int[] b = fb.apply(SPECIES.length());
2892         int[] r = fr.apply(SPECIES.length());
2893 
2894         for (int i = 0; i < a.length; i += SPECIES.length()) {
2895             IntVector av = IntVector.fromArray(SPECIES, a, i);
2896             IntVector bv = IntVector.fromArray(SPECIES, b, i);
2897             av.min(bv).intoArray(r, i);
2898         }
2899 
2900         assertArraysEquals(r, a, b, IntMaxVectorTests::min);
2901     }

2902     static int MAX(int a, int b) {
2903         return (int)(Math.max(a, b));
2904     }
2905 
2906     @Test(dataProvider = "intBinaryOpProvider")
2907     static void MAXIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2908         int[] a = fa.apply(SPECIES.length());
2909         int[] b = fb.apply(SPECIES.length());
2910         int[] r = fr.apply(SPECIES.length());
2911 
2912         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2913             for (int i = 0; i < a.length; i += SPECIES.length()) {
2914                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2915                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2916                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2917             }
2918         }
2919 
2920         assertArraysEquals(r, a, b, IntMaxVectorTests::MAX);
2921     }

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

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

3272                 IntMaxVectorTests::XORReduceMasked, IntMaxVectorTests::XORReduceAllMasked);
3273     }
3274 
3275     static int ADDReduce(int[] a, int idx) {
3276         int res = 0;
3277         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3278             res += a[i];
3279         }
3280 
3281         return res;
3282     }
3283 
3284     static int ADDReduceAll(int[] a) {
3285         int res = 0;
3286         for (int i = 0; i < a.length; i += SPECIES.length()) {
3287             res += ADDReduce(a, i);
3288         }
3289 
3290         return res;
3291     }

3292     @Test(dataProvider = "intUnaryOpProvider")
3293     static void ADDReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3294         int[] a = fa.apply(SPECIES.length());
3295         int[] r = fr.apply(SPECIES.length());
3296         int ra = 0;
3297 
3298         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3299             for (int i = 0; i < a.length; i += SPECIES.length()) {
3300                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3301                 r[i] = av.reduceLanes(VectorOperators.ADD);
3302             }
3303         }
3304 
3305         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3306             ra = 0;
3307             for (int i = 0; i < a.length; i += SPECIES.length()) {
3308                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3309                 ra += av.reduceLanes(VectorOperators.ADD);
3310             }
3311         }
3312 
3313         assertReductionArraysEquals(r, ra, a,
3314                 IntMaxVectorTests::ADDReduce, IntMaxVectorTests::ADDReduceAll);
3315     }

3316     static int ADDReduceMasked(int[] a, int idx, boolean[] mask) {
3317         int res = 0;
3318         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3319             if (mask[i % SPECIES.length()])
3320                 res += a[i];
3321         }
3322 
3323         return res;
3324     }
3325 
3326     static int ADDReduceAllMasked(int[] a, boolean[] mask) {
3327         int res = 0;
3328         for (int i = 0; i < a.length; i += SPECIES.length()) {
3329             res += ADDReduceMasked(a, i, mask);
3330         }
3331 
3332         return res;
3333     }

3334     @Test(dataProvider = "intUnaryOpMaskProvider")
3335     static void ADDReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3336         int[] a = fa.apply(SPECIES.length());
3337         int[] r = fr.apply(SPECIES.length());
3338         boolean[] mask = fm.apply(SPECIES.length());
3339         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3340         int ra = 0;
3341 
3342         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3343             for (int i = 0; i < a.length; i += SPECIES.length()) {
3344                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3345                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3346             }
3347         }
3348 
3349         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3350             ra = 0;
3351             for (int i = 0; i < a.length; i += SPECIES.length()) {
3352                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3353                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3354             }
3355         }
3356 
3357         assertReductionArraysEqualsMasked(r, ra, a, mask,
3358                 IntMaxVectorTests::ADDReduceMasked, IntMaxVectorTests::ADDReduceAllMasked);
3359     }

3360     static int MULReduce(int[] a, int idx) {
3361         int res = 1;
3362         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3363             res *= a[i];
3364         }
3365 
3366         return res;
3367     }
3368 
3369     static int MULReduceAll(int[] a) {
3370         int res = 1;
3371         for (int i = 0; i < a.length; i += SPECIES.length()) {
3372             res *= MULReduce(a, i);
3373         }
3374 
3375         return res;
3376     }

3377     @Test(dataProvider = "intUnaryOpProvider")
3378     static void MULReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3379         int[] a = fa.apply(SPECIES.length());
3380         int[] r = fr.apply(SPECIES.length());
3381         int ra = 1;
3382 
3383         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3384             for (int i = 0; i < a.length; i += SPECIES.length()) {
3385                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3386                 r[i] = av.reduceLanes(VectorOperators.MUL);
3387             }
3388         }
3389 
3390         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3391             ra = 1;
3392             for (int i = 0; i < a.length; i += SPECIES.length()) {
3393                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3394                 ra *= av.reduceLanes(VectorOperators.MUL);
3395             }
3396         }
3397 
3398         assertReductionArraysEquals(r, ra, a,
3399                 IntMaxVectorTests::MULReduce, IntMaxVectorTests::MULReduceAll);
3400     }

3401     static int MULReduceMasked(int[] a, int idx, boolean[] mask) {
3402         int res = 1;
3403         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3404             if (mask[i % SPECIES.length()])
3405                 res *= a[i];
3406         }
3407 
3408         return res;
3409     }
3410 
3411     static int MULReduceAllMasked(int[] a, boolean[] mask) {
3412         int res = 1;
3413         for (int i = 0; i < a.length; i += SPECIES.length()) {
3414             res *= MULReduceMasked(a, i, mask);
3415         }
3416 
3417         return res;
3418     }

3419     @Test(dataProvider = "intUnaryOpMaskProvider")
3420     static void MULReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3421         int[] a = fa.apply(SPECIES.length());
3422         int[] r = fr.apply(SPECIES.length());
3423         boolean[] mask = fm.apply(SPECIES.length());
3424         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3425         int ra = 1;
3426 
3427         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3428             for (int i = 0; i < a.length; i += SPECIES.length()) {
3429                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3430                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3431             }
3432         }
3433 
3434         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3435             ra = 1;
3436             for (int i = 0; i < a.length; i += SPECIES.length()) {
3437                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3438                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
3439             }
3440         }
3441 
3442         assertReductionArraysEqualsMasked(r, ra, a, mask,
3443                 IntMaxVectorTests::MULReduceMasked, IntMaxVectorTests::MULReduceAllMasked);
3444     }

3445     static int MINReduce(int[] a, int idx) {
3446         int res = Integer.MAX_VALUE;
3447         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3448             res = (int) Math.min(res, a[i]);
3449         }
3450 
3451         return res;
3452     }
3453 
3454     static int MINReduceAll(int[] a) {
3455         int res = Integer.MAX_VALUE;
3456         for (int i = 0; i < a.length; i += SPECIES.length()) {
3457             res = (int) Math.min(res, MINReduce(a, i));
3458         }
3459 
3460         return res;
3461     }

3462     @Test(dataProvider = "intUnaryOpProvider")
3463     static void MINReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3464         int[] a = fa.apply(SPECIES.length());
3465         int[] r = fr.apply(SPECIES.length());
3466         int ra = Integer.MAX_VALUE;
3467 
3468         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3469             for (int i = 0; i < a.length; i += SPECIES.length()) {
3470                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3471                 r[i] = av.reduceLanes(VectorOperators.MIN);
3472             }
3473         }
3474 
3475         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3476             ra = Integer.MAX_VALUE;
3477             for (int i = 0; i < a.length; i += SPECIES.length()) {
3478                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3479                 ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
3480             }
3481         }
3482 
3483         assertReductionArraysEquals(r, ra, a,
3484                 IntMaxVectorTests::MINReduce, IntMaxVectorTests::MINReduceAll);
3485     }

3486     static int MINReduceMasked(int[] a, int idx, boolean[] mask) {
3487         int res = Integer.MAX_VALUE;
3488         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3489             if (mask[i % SPECIES.length()])
3490                 res = (int) Math.min(res, a[i]);
3491         }
3492 
3493         return res;
3494     }
3495 
3496     static int MINReduceAllMasked(int[] a, boolean[] mask) {
3497         int res = Integer.MAX_VALUE;
3498         for (int i = 0; i < a.length; i += SPECIES.length()) {
3499             res = (int) Math.min(res, MINReduceMasked(a, i, mask));
3500         }
3501 
3502         return res;
3503     }

3504     @Test(dataProvider = "intUnaryOpMaskProvider")
3505     static void MINReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3506         int[] a = fa.apply(SPECIES.length());
3507         int[] r = fr.apply(SPECIES.length());
3508         boolean[] mask = fm.apply(SPECIES.length());
3509         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3510         int ra = Integer.MAX_VALUE;
3511 
3512         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3513             for (int i = 0; i < a.length; i += SPECIES.length()) {
3514                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3515                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
3516             }
3517         }
3518 
3519         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3520             ra = Integer.MAX_VALUE;
3521             for (int i = 0; i < a.length; i += SPECIES.length()) {
3522                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3523                 ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
3524             }
3525         }
3526 
3527         assertReductionArraysEqualsMasked(r, ra, a, mask,
3528                 IntMaxVectorTests::MINReduceMasked, IntMaxVectorTests::MINReduceAllMasked);
3529     }

3530     static int MAXReduce(int[] a, int idx) {
3531         int res = Integer.MIN_VALUE;
3532         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3533             res = (int) Math.max(res, a[i]);
3534         }
3535 
3536         return res;
3537     }
3538 
3539     static int MAXReduceAll(int[] a) {
3540         int res = Integer.MIN_VALUE;
3541         for (int i = 0; i < a.length; i += SPECIES.length()) {
3542             res = (int) Math.max(res, MAXReduce(a, i));
3543         }
3544 
3545         return res;
3546     }

3547     @Test(dataProvider = "intUnaryOpProvider")
3548     static void MAXReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3549         int[] a = fa.apply(SPECIES.length());
3550         int[] r = fr.apply(SPECIES.length());
3551         int ra = Integer.MIN_VALUE;
3552 
3553         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3554             for (int i = 0; i < a.length; i += SPECIES.length()) {
3555                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3556                 r[i] = av.reduceLanes(VectorOperators.MAX);
3557             }
3558         }
3559 
3560         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3561             ra = Integer.MIN_VALUE;
3562             for (int i = 0; i < a.length; i += SPECIES.length()) {
3563                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3564                 ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
3565             }
3566         }
3567 
3568         assertReductionArraysEquals(r, ra, a,
3569                 IntMaxVectorTests::MAXReduce, IntMaxVectorTests::MAXReduceAll);
3570     }

3571     static int MAXReduceMasked(int[] a, int idx, boolean[] mask) {
3572         int res = Integer.MIN_VALUE;
3573         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3574             if (mask[i % SPECIES.length()])
3575                 res = (int) Math.max(res, a[i]);
3576         }
3577 
3578         return res;
3579     }
3580 
3581     static int MAXReduceAllMasked(int[] a, boolean[] mask) {
3582         int res = Integer.MIN_VALUE;
3583         for (int i = 0; i < a.length; i += SPECIES.length()) {
3584             res = (int) Math.max(res, MAXReduceMasked(a, i, mask));
3585         }
3586 
3587         return res;
3588     }

3589     @Test(dataProvider = "intUnaryOpMaskProvider")
3590     static void MAXReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3591         int[] a = fa.apply(SPECIES.length());
3592         int[] r = fr.apply(SPECIES.length());
3593         boolean[] mask = fm.apply(SPECIES.length());
3594         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3595         int ra = Integer.MIN_VALUE;
3596 
3597         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3598             for (int i = 0; i < a.length; i += SPECIES.length()) {
3599                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3600                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
3601             }
3602         }
3603 
3604         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3605             ra = Integer.MIN_VALUE;
3606             for (int i = 0; i < a.length; i += SPECIES.length()) {
3607                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3608                 ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
3609             }
3610         }
3611 
3612         assertReductionArraysEqualsMasked(r, ra, a, mask,
3613                 IntMaxVectorTests::MAXReduceMasked, IntMaxVectorTests::MAXReduceAllMasked);
3614     }

3615     static int FIRST_NONZEROReduce(int[] a, int idx) {
3616         int res = (int) 0;
3617         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3618             res = firstNonZero(res, a[i]);
3619         }
3620 
3621         return res;
3622     }
3623 
3624     static int FIRST_NONZEROReduceAll(int[] a) {
3625         int res = (int) 0;
3626         for (int i = 0; i < a.length; i += SPECIES.length()) {
3627             res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
3628         }
3629 
3630         return res;
3631     }

3632     @Test(dataProvider = "intUnaryOpProvider")
3633     static void FIRST_NONZEROReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3634         int[] a = fa.apply(SPECIES.length());
3635         int[] r = fr.apply(SPECIES.length());
3636         int ra = (int) 0;
3637 
3638         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3639             for (int i = 0; i < a.length; i += SPECIES.length()) {
3640                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3641                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
3642             }
3643         }
3644 
3645         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3646             ra = (int) 0;
3647             for (int i = 0; i < a.length; i += SPECIES.length()) {
3648                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3649                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
3650             }
3651         }
3652 
3653         assertReductionArraysEquals(r, ra, a,
3654                 IntMaxVectorTests::FIRST_NONZEROReduce, IntMaxVectorTests::FIRST_NONZEROReduceAll);
3655     }

3656     static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) {
3657         int res = (int) 0;
3658         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3659             if (mask[i % SPECIES.length()])
3660                 res = firstNonZero(res, a[i]);
3661         }
3662 
3663         return res;
3664     }
3665 
3666     static int FIRST_NONZEROReduceAllMasked(int[] a, boolean[] mask) {
3667         int res = (int) 0;
3668         for (int i = 0; i < a.length; i += SPECIES.length()) {
3669             res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
3670         }
3671 
3672         return res;
3673     }

3674     @Test(dataProvider = "intUnaryOpMaskProvider")
3675     static void FIRST_NONZEROReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3676         int[] a = fa.apply(SPECIES.length());
3677         int[] r = fr.apply(SPECIES.length());
3678         boolean[] mask = fm.apply(SPECIES.length());
3679         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3680         int ra = (int) 0;
3681 
3682         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3683             for (int i = 0; i < a.length; i += SPECIES.length()) {
3684                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3685                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
3686             }
3687         }
3688 
3689         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3690             ra = (int) 0;
3691             for (int i = 0; i < a.length; i += SPECIES.length()) {
3692                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3693                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
3694             }
3695         }
3696 
3697         assertReductionArraysEqualsMasked(r, ra, a, mask,
3698                 IntMaxVectorTests::FIRST_NONZEROReduceMasked, IntMaxVectorTests::FIRST_NONZEROReduceAllMasked);
3699     }
3700 
3701     static boolean anyTrue(boolean[] a, int idx) {
3702         boolean res = false;
3703         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3704             res |= a[i];
3705         }
3706 
3707         return res;
3708     }
3709 
3710 
3711     @Test(dataProvider = "boolUnaryOpProvider")
3712     static void anyTrueIntMaxVectorTests(IntFunction<boolean[]> fm) {
3713         boolean[] mask = fm.apply(SPECIES.length());
3714         boolean[] r = fmr.apply(SPECIES.length());
3715 
3716         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3717             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3718                 VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, i);
3719                 r[i] = vmask.anyTrue();
3720             }
3721         }
3722 
3723         assertReductionBoolArraysEquals(r, mask, IntMaxVectorTests::anyTrue);
3724     }
3725 
3726 
3727     static boolean allTrue(boolean[] a, int idx) {
3728         boolean res = true;
3729         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3730             res &= a[i];
3731         }
3732 
3733         return res;
3734     }
3735 
3736 
3737     @Test(dataProvider = "boolUnaryOpProvider")
3738     static void allTrueIntMaxVectorTests(IntFunction<boolean[]> fm) {
3739         boolean[] mask = fm.apply(SPECIES.length());
3740         boolean[] r = fmr.apply(SPECIES.length());
3741 
3742         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3743             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3744                 VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, i);
3745                 r[i] = vmask.allTrue();
3746             }
3747         }
3748 
3749         assertReductionBoolArraysEquals(r, mask, IntMaxVectorTests::allTrue);
3750     }
3751 
3752 
3753     @Test(dataProvider = "intUnaryOpProvider")
3754     static void withIntMaxVectorTests(IntFunction<int []> fa) {
3755         int[] a = fa.apply(SPECIES.length());
3756         int[] r = fr.apply(SPECIES.length());
3757 
3758         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3759             for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3760                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3761                 av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i);
3762             }
3763         }
3764 
3765 
3766         for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3767             assertInsertArraysEquals(r, a, (int)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
3768         }
3769     }

3770     static boolean testIS_DEFAULT(int a) {
3771         return bits(a)==0;
3772     }
3773 
3774     @Test(dataProvider = "intTestOpProvider")
3775     static void IS_DEFAULTIntMaxVectorTests(IntFunction<int[]> fa) {
3776         int[] a = fa.apply(SPECIES.length());
3777 
3778         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3779             for (int i = 0; i < a.length; i += SPECIES.length()) {
3780                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3781                 VectorMask<Integer> mv = av.test(VectorOperators.IS_DEFAULT);
3782 
3783                 // Check results as part of computation.
3784                 for (int j = 0; j < SPECIES.length(); j++) {
3785                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3786                 }
3787             }
3788         }
3789     }
3790 
3791     @Test(dataProvider = "intTestOpMaskProvider")
3792     static void IS_DEFAULTMaskedIntMaxVectorTests(IntFunction<int[]> fa,
3793                                           IntFunction<boolean[]> fm) {
3794         int[] a = fa.apply(SPECIES.length());
3795         boolean[] mask = fm.apply(SPECIES.length());
3796         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3797 
3798         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3799             for (int i = 0; i < a.length; i += SPECIES.length()) {
3800                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3801                 VectorMask<Integer> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3802 
3803                 // Check results as part of computation.
3804                 for (int j = 0; j < SPECIES.length(); j++) {
3805                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3806                 }
3807             }
3808         }
3809     }

3810     static boolean testIS_NEGATIVE(int a) {
3811         return bits(a)<0;
3812     }
3813 
3814     @Test(dataProvider = "intTestOpProvider")
3815     static void IS_NEGATIVEIntMaxVectorTests(IntFunction<int[]> fa) {
3816         int[] a = fa.apply(SPECIES.length());
3817 
3818         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3819             for (int i = 0; i < a.length; i += SPECIES.length()) {
3820                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3821                 VectorMask<Integer> mv = av.test(VectorOperators.IS_NEGATIVE);
3822 
3823                 // Check results as part of computation.
3824                 for (int j = 0; j < SPECIES.length(); j++) {
3825                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3826                 }
3827             }
3828         }
3829     }

3831     @Test(dataProvider = "intTestOpMaskProvider")
3832     static void IS_NEGATIVEMaskedIntMaxVectorTests(IntFunction<int[]> fa,
3833                                           IntFunction<boolean[]> fm) {
3834         int[] a = fa.apply(SPECIES.length());
3835         boolean[] mask = fm.apply(SPECIES.length());
3836         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3837 
3838         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3839             for (int i = 0; i < a.length; i += SPECIES.length()) {
3840                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3841                 VectorMask<Integer> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3842 
3843                 // Check results as part of computation.
3844                 for (int j = 0; j < SPECIES.length(); j++) {
3845                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3846                 }
3847             }
3848         }
3849     }
3850 
3851 
3852 
3853 
3854     @Test(dataProvider = "intCompareOpProvider")
3855     static void LTIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3856         int[] a = fa.apply(SPECIES.length());
3857         int[] b = fb.apply(SPECIES.length());
3858 
3859         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3860             for (int i = 0; i < a.length; i += SPECIES.length()) {
3861                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3862                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3863                 VectorMask<Integer> mv = av.compare(VectorOperators.LT, bv);
3864 
3865                 // Check results as part of computation.
3866                 for (int j = 0; j < SPECIES.length(); j++) {
3867                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3868                 }
3869             }
3870         }
3871     }
3872 
3873 
3874     @Test(dataProvider = "intCompareOpProvider")
3875     static void ltIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3876         int[] a = fa.apply(SPECIES.length());
3877         int[] 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                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3882                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3883                 VectorMask<Integer> mv = av.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     @Test(dataProvider = "intCompareOpMaskProvider")

3896         int[] a = fa.apply(SPECIES.length());
3897         int[] b = fb.apply(SPECIES.length());
3898         boolean[] mask = fm.apply(SPECIES.length());
3899 
3900         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3901 
3902         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3903             for (int i = 0; i < a.length; i += SPECIES.length()) {
3904                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3905                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3906                 VectorMask<Integer> mv = av.compare(VectorOperators.LT, bv, vmask);
3907 
3908                 // Check results as part of computation.
3909                 for (int j = 0; j < SPECIES.length(); j++) {
3910                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3911                 }
3912             }
3913         }
3914     }
3915 
3916 
3917     @Test(dataProvider = "intCompareOpProvider")
3918     static void GTIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3919         int[] a = fa.apply(SPECIES.length());
3920         int[] b = fb.apply(SPECIES.length());
3921 
3922         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3923             for (int i = 0; i < a.length; i += SPECIES.length()) {
3924                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3925                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3926                 VectorMask<Integer> mv = av.compare(VectorOperators.GT, bv);
3927 
3928                 // Check results as part of computation.
3929                 for (int j = 0; j < SPECIES.length(); j++) {
3930                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3931                 }
3932             }
3933         }
3934     }
3935 
3936     @Test(dataProvider = "intCompareOpMaskProvider")

3939         int[] a = fa.apply(SPECIES.length());
3940         int[] b = fb.apply(SPECIES.length());
3941         boolean[] mask = fm.apply(SPECIES.length());
3942 
3943         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3944 
3945         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3946             for (int i = 0; i < a.length; i += SPECIES.length()) {
3947                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3948                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3949                 VectorMask<Integer> mv = av.compare(VectorOperators.GT, bv, vmask);
3950 
3951                 // Check results as part of computation.
3952                 for (int j = 0; j < SPECIES.length(); j++) {
3953                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && gt(a[i + j], b[i + j]));
3954                 }
3955             }
3956         }
3957     }
3958 
3959 
3960     @Test(dataProvider = "intCompareOpProvider")
3961     static void EQIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3962         int[] a = fa.apply(SPECIES.length());
3963         int[] b = fb.apply(SPECIES.length());
3964 
3965         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3966             for (int i = 0; i < a.length; i += SPECIES.length()) {
3967                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3968                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3969                 VectorMask<Integer> mv = av.compare(VectorOperators.EQ, bv);
3970 
3971                 // Check results as part of computation.
3972                 for (int j = 0; j < SPECIES.length(); j++) {
3973                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
3974                 }
3975             }
3976         }
3977     }
3978 
3979 
3980     @Test(dataProvider = "intCompareOpProvider")
3981     static void eqIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3982         int[] a = fa.apply(SPECIES.length());
3983         int[] 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                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3988                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3989                 VectorMask<Integer> mv = av.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     @Test(dataProvider = "intCompareOpMaskProvider")

4002         int[] a = fa.apply(SPECIES.length());
4003         int[] b = fb.apply(SPECIES.length());
4004         boolean[] mask = fm.apply(SPECIES.length());
4005 
4006         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4007 
4008         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4009             for (int i = 0; i < a.length; i += SPECIES.length()) {
4010                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4011                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4012                 VectorMask<Integer> mv = av.compare(VectorOperators.EQ, bv, vmask);
4013 
4014                 // Check results as part of computation.
4015                 for (int j = 0; j < SPECIES.length(); j++) {
4016                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
4017                 }
4018             }
4019         }
4020     }
4021 
4022 
4023     @Test(dataProvider = "intCompareOpProvider")
4024     static void NEIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4025         int[] a = fa.apply(SPECIES.length());
4026         int[] b = fb.apply(SPECIES.length());
4027 
4028         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4029             for (int i = 0; i < a.length; i += SPECIES.length()) {
4030                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4031                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4032                 VectorMask<Integer> mv = av.compare(VectorOperators.NE, bv);
4033 
4034                 // Check results as part of computation.
4035                 for (int j = 0; j < SPECIES.length(); j++) {
4036                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
4037                 }
4038             }
4039         }
4040     }
4041 
4042     @Test(dataProvider = "intCompareOpMaskProvider")

4045         int[] a = fa.apply(SPECIES.length());
4046         int[] b = fb.apply(SPECIES.length());
4047         boolean[] mask = fm.apply(SPECIES.length());
4048 
4049         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4050 
4051         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4052             for (int i = 0; i < a.length; i += SPECIES.length()) {
4053                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4054                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4055                 VectorMask<Integer> mv = av.compare(VectorOperators.NE, bv, vmask);
4056 
4057                 // Check results as part of computation.
4058                 for (int j = 0; j < SPECIES.length(); j++) {
4059                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
4060                 }
4061             }
4062         }
4063     }
4064 
4065 
4066     @Test(dataProvider = "intCompareOpProvider")
4067     static void LEIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4068         int[] a = fa.apply(SPECIES.length());
4069         int[] b = fb.apply(SPECIES.length());
4070 
4071         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4072             for (int i = 0; i < a.length; i += SPECIES.length()) {
4073                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4074                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4075                 VectorMask<Integer> mv = av.compare(VectorOperators.LE, bv);
4076 
4077                 // Check results as part of computation.
4078                 for (int j = 0; j < SPECIES.length(); j++) {
4079                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
4080                 }
4081             }
4082         }
4083     }
4084 
4085     @Test(dataProvider = "intCompareOpMaskProvider")

4088         int[] a = fa.apply(SPECIES.length());
4089         int[] b = fb.apply(SPECIES.length());
4090         boolean[] mask = fm.apply(SPECIES.length());
4091 
4092         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4093 
4094         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4095             for (int i = 0; i < a.length; i += SPECIES.length()) {
4096                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4097                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4098                 VectorMask<Integer> mv = av.compare(VectorOperators.LE, bv, vmask);
4099 
4100                 // Check results as part of computation.
4101                 for (int j = 0; j < SPECIES.length(); j++) {
4102                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
4103                 }
4104             }
4105         }
4106     }
4107 
4108 
4109     @Test(dataProvider = "intCompareOpProvider")
4110     static void GEIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4111         int[] a = fa.apply(SPECIES.length());
4112         int[] b = fb.apply(SPECIES.length());
4113 
4114         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4115             for (int i = 0; i < a.length; i += SPECIES.length()) {
4116                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4117                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4118                 VectorMask<Integer> mv = av.compare(VectorOperators.GE, bv);
4119 
4120                 // Check results as part of computation.
4121                 for (int j = 0; j < SPECIES.length(); j++) {
4122                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
4123                 }
4124             }
4125         }
4126     }
4127 
4128     @Test(dataProvider = "intCompareOpMaskProvider")

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

4526         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
4527     }
4528 
4529     @Test(dataProvider = "intUnaryOpShuffleMaskProvider")
4530     static void RearrangeIntMaxVectorTestsMaskedSmokeTest(IntFunction<int[]> fa,
4531                                                           BiFunction<Integer,Integer,int[]> fs,
4532                                                           IntFunction<boolean[]> fm) {
4533         int[] a = fa.apply(SPECIES.length());
4534         int[] order = fs.apply(a.length, SPECIES.length());
4535         int[] r = fr.apply(SPECIES.length());
4536         boolean[] mask = fm.apply(SPECIES.length());
4537         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4538 
4539         for (int i = 0; i < a.length; i += SPECIES.length()) {
4540             IntVector av = IntVector.fromArray(SPECIES, a, i);
4541             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
4542         }
4543 
4544         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
4545     }





































4546     @Test(dataProvider = "intUnaryOpProvider")
4547     static void getIntMaxVectorTests(IntFunction<int[]> fa) {
4548         int[] a = fa.apply(SPECIES.length());
4549         int[] r = fr.apply(SPECIES.length());
4550 
4551         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4552             for (int i = 0; i < a.length; i += SPECIES.length()) {
4553                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4554                 int num_lanes = SPECIES.length();
4555                 // Manually unroll because full unroll happens after intrinsification.
4556                 // Unroll is needed because get intrinsic requires for index to be a known constant.
4557                 if (num_lanes == 1) {
4558                     r[i]=av.lane(0);
4559                 } else if (num_lanes == 2) {
4560                     r[i]=av.lane(0);
4561                     r[i+1]=av.lane(1);
4562                 } else if (num_lanes == 4) {
4563                     r[i]=av.lane(0);
4564                     r[i+1]=av.lane(1);
4565                     r[i+2]=av.lane(2);

4696             }
4697         }
4698 
4699         assertArraysEquals(r, a, IntMaxVectorTests::get);
4700     }
4701 
4702     @Test(dataProvider = "intUnaryOpProvider")
4703     static void BroadcastIntMaxVectorTests(IntFunction<int[]> fa) {
4704         int[] a = fa.apply(SPECIES.length());
4705         int[] r = new int[a.length];
4706 
4707         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4708             for (int i = 0; i < a.length; i += SPECIES.length()) {
4709                 IntVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4710             }
4711         }
4712 
4713         assertBroadcastArraysEquals(r, a);
4714     }
4715 
4716 
4717 
4718 
4719 
4720     @Test(dataProvider = "intUnaryOpProvider")
4721     static void ZeroIntMaxVectorTests(IntFunction<int[]> fa) {
4722         int[] a = fa.apply(SPECIES.length());
4723         int[] r = new int[a.length];
4724 
4725         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4726             for (int i = 0; i < a.length; i += SPECIES.length()) {
4727                 IntVector.zero(SPECIES).intoArray(a, i);
4728             }
4729         }
4730 
4731         Assert.assertEquals(a, r);
4732     }
4733 
4734 
4735 
4736 
4737     static int[] sliceUnary(int[] a, int origin, int idx) {
4738         int[] res = new int[SPECIES.length()];
4739         for (int i = 0; i < SPECIES.length(); i++){
4740             if(i+origin < SPECIES.length())
4741                 res[i] = a[idx+i+origin];
4742             else
4743                 res[i] = (int)0;
4744         }
4745         return res;
4746     }
4747 
4748     @Test(dataProvider = "intUnaryOpProvider")
4749     static void sliceUnaryIntMaxVectorTests(IntFunction<int[]> fa) {
4750         int[] a = fa.apply(SPECIES.length());
4751         int[] r = new int[a.length];
4752         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4753         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4754             for (int i = 0; i < a.length; i += SPECIES.length()) {
4755                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4756                 av.slice(origin).intoArray(r, i);
4757             }
4758         }
4759 
4760         assertArraysEquals(r, a, origin, IntMaxVectorTests::sliceUnary);
4761     }

4762     static int[] sliceBinary(int[] a, int[] b, int origin, int idx) {
4763         int[] res = new int[SPECIES.length()];
4764         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4765             if(i+origin < SPECIES.length())
4766                 res[i] = a[idx+i+origin];
4767             else {
4768                 res[i] = b[idx+j];
4769                 j++;
4770             }
4771         }
4772         return res;
4773     }
4774 
4775     @Test(dataProvider = "intBinaryOpProvider")
4776     static void sliceBinaryIntMaxVectorTestsBinary(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4777         int[] a = fa.apply(SPECIES.length());
4778         int[] b = fb.apply(SPECIES.length());
4779         int[] r = new int[a.length];
4780         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4781         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4782             for (int i = 0; i < a.length; i += SPECIES.length()) {
4783                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4784                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4785                 av.slice(origin, bv).intoArray(r, i);
4786             }
4787         }
4788 
4789         assertArraysEquals(r, a, b, origin, IntMaxVectorTests::sliceBinary);
4790     }

4791     static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) {
4792         int[] res = new int[SPECIES.length()];
4793         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4794             if(i+origin < SPECIES.length())
4795                 res[i] = mask[i] ? a[idx+i+origin] : (int)0;
4796             else {
4797                 res[i] = mask[i] ? b[idx+j] : (int)0;
4798                 j++;
4799             }
4800         }
4801         return res;
4802     }
4803 
4804     @Test(dataProvider = "intBinaryOpMaskProvider")
4805     static void sliceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4806     IntFunction<boolean[]> fm) {
4807         int[] a = fa.apply(SPECIES.length());
4808         int[] b = fb.apply(SPECIES.length());
4809         boolean[] mask = fm.apply(SPECIES.length());
4810         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4811 
4812         int[] r = new int[a.length];
4813         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4814         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4815             for (int i = 0; i < a.length; i += SPECIES.length()) {
4816                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4817                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4818                 av.slice(origin, bv, vmask).intoArray(r, i);
4819             }
4820         }
4821 
4822         assertArraysEquals(r, a, b, origin, mask, IntMaxVectorTests::slice);
4823     }

4824     static int[] unsliceUnary(int[] a, int origin, int idx) {
4825         int[] res = new int[SPECIES.length()];
4826         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4827             if(i < origin)
4828                 res[i] = (int)0;
4829             else {
4830                 res[i] = a[idx+j];
4831                 j++;
4832             }
4833         }
4834         return res;
4835     }
4836 
4837     @Test(dataProvider = "intUnaryOpProvider")
4838     static void unsliceUnaryIntMaxVectorTests(IntFunction<int[]> fa) {
4839         int[] a = fa.apply(SPECIES.length());
4840         int[] r = new int[a.length];
4841         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4842         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4843             for (int i = 0; i < a.length; i += SPECIES.length()) {
4844                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4845                 av.unslice(origin).intoArray(r, i);
4846             }
4847         }
4848 
4849         assertArraysEquals(r, a, origin, IntMaxVectorTests::unsliceUnary);
4850     }

4851     static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) {
4852         int[] res = new int[SPECIES.length()];
4853         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4854             if (part == 0) {
4855                 if (i < origin)
4856                     res[i] = b[idx+i];
4857                 else {
4858                     res[i] = a[idx+j];
4859                     j++;
4860                 }
4861             } else if (part == 1) {
4862                 if (i < origin)
4863                     res[i] = a[idx+SPECIES.length()-origin+i];
4864                 else {
4865                     res[i] = b[idx+origin+j];
4866                     j++;
4867                 }
4868             }
4869         }
4870         return res;
4871     }
4872 
4873     @Test(dataProvider = "intBinaryOpProvider")
4874     static void unsliceBinaryIntMaxVectorTestsBinary(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4875         int[] a = fa.apply(SPECIES.length());
4876         int[] b = fb.apply(SPECIES.length());
4877         int[] r = new int[a.length];
4878         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4879         int part = (new java.util.Random()).nextInt(2);
4880         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4881             for (int i = 0; i < a.length; i += SPECIES.length()) {
4882                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4883                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4884                 av.unslice(origin, bv, part).intoArray(r, i);
4885             }
4886         }
4887 
4888         assertArraysEquals(r, a, b, origin, part, IntMaxVectorTests::unsliceBinary);
4889     }

4890     static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) {
4891         int[] res = new int[SPECIES.length()];
4892         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4893             if(i+origin < SPECIES.length())
4894                 res[i] = b[idx+i+origin];
4895             else {
4896                 res[i] = b[idx+j];
4897                 j++;
4898             }
4899         }
4900         for (int i = 0; i < SPECIES.length(); i++){
4901             res[i] = mask[i] ? a[idx+i] : res[i];
4902         }
4903         int[] res1 = new int[SPECIES.length()];
4904         if (part == 0) {
4905             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4906                 if (i < origin)
4907                     res1[i] = b[idx+i];
4908                 else {
4909                    res1[i] = res[j];

4927     static void unsliceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4928     IntFunction<boolean[]> fm) {
4929         int[] a = fa.apply(SPECIES.length());
4930         int[] b = fb.apply(SPECIES.length());
4931         boolean[] mask = fm.apply(SPECIES.length());
4932         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4933         int[] r = new int[a.length];
4934         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4935         int part = (new java.util.Random()).nextInt(2);
4936         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4937             for (int i = 0; i < a.length; i += SPECIES.length()) {
4938                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4939                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4940                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
4941             }
4942         }
4943 
4944         assertArraysEquals(r, a, b, origin, part, mask, IntMaxVectorTests::unslice);
4945     }
4946 
4947 
4948 
4949 
4950 
4951 
4952 
4953 
4954 
4955 
4956 
4957 
4958 
4959 
4960 
4961 
4962 
4963 
4964 
4965 
4966 
4967 
4968 
4969     static int BITWISE_BLEND(int a, int b, int c) {
4970         return (int)((a&~(c))|(b&c));
4971     }

4972     static int bitwiseBlend(int a, int b, int c) {
4973         return (int)((a&~(c))|(b&c));
4974     }
4975 
4976 
4977     @Test(dataProvider = "intTernaryOpProvider")
4978     static void BITWISE_BLENDIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
4979         int[] a = fa.apply(SPECIES.length());
4980         int[] b = fb.apply(SPECIES.length());
4981         int[] c = fc.apply(SPECIES.length());
4982         int[] r = fr.apply(SPECIES.length());
4983 
4984         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4985             for (int i = 0; i < a.length; i += SPECIES.length()) {
4986                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4987                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4988                 IntVector cv = IntVector.fromArray(SPECIES, c, i);
4989                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
4990             }
4991         }
4992 
4993         assertArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND);
4994     }

4995     @Test(dataProvider = "intTernaryOpProvider")
4996     static void bitwiseBlendIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
4997         int[] a = fa.apply(SPECIES.length());
4998         int[] b = fb.apply(SPECIES.length());
4999         int[] c = fc.apply(SPECIES.length());
5000         int[] r = fr.apply(SPECIES.length());
5001 
5002         for (int i = 0; i < a.length; i += SPECIES.length()) {
5003             IntVector av = IntVector.fromArray(SPECIES, a, i);
5004             IntVector bv = IntVector.fromArray(SPECIES, b, i);
5005             IntVector cv = IntVector.fromArray(SPECIES, c, i);
5006             av.bitwiseBlend(bv, cv).intoArray(r, i);
5007         }
5008 
5009         assertArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend);
5010     }
5011 
5012 
5013     @Test(dataProvider = "intTernaryOpMaskProvider")
5014     static void BITWISE_BLENDIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
5015                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
5016         int[] a = fa.apply(SPECIES.length());
5017         int[] b = fb.apply(SPECIES.length());
5018         int[] c = fc.apply(SPECIES.length());
5019         int[] r = fr.apply(SPECIES.length());
5020         boolean[] mask = fm.apply(SPECIES.length());
5021         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5022 
5023         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5024             for (int i = 0; i < a.length; i += SPECIES.length()) {
5025                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5026                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
5027                 IntVector cv = IntVector.fromArray(SPECIES, c, i);
5028                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
5029             }
5030         }
5031 
5032         assertArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND);
5033     }
5034 
5035 
5036 
5037 
5038     @Test(dataProvider = "intTernaryOpProvider")
5039     static void BITWISE_BLENDIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5040         int[] a = fa.apply(SPECIES.length());
5041         int[] b = fb.apply(SPECIES.length());
5042         int[] c = fc.apply(SPECIES.length());
5043         int[] r = fr.apply(SPECIES.length());
5044 
5045         for (int i = 0; i < a.length; i += SPECIES.length()) {
5046             IntVector av = IntVector.fromArray(SPECIES, a, i);
5047             IntVector bv = IntVector.fromArray(SPECIES, b, i);
5048             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
5049         }
5050         assertBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND);
5051     }
5052 
5053     @Test(dataProvider = "intTernaryOpProvider")
5054     static void BITWISE_BLENDIntMaxVectorTestsAltBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5055         int[] a = fa.apply(SPECIES.length());
5056         int[] b = fb.apply(SPECIES.length());
5057         int[] c = fc.apply(SPECIES.length());
5058         int[] r = fr.apply(SPECIES.length());
5059 
5060         for (int i = 0; i < a.length; i += SPECIES.length()) {
5061             IntVector av = IntVector.fromArray(SPECIES, a, i);
5062             IntVector cv = IntVector.fromArray(SPECIES, c, i);
5063             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
5064         }
5065         assertAltBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND);
5066     }

5067     @Test(dataProvider = "intTernaryOpProvider")
5068     static void bitwiseBlendIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5069         int[] a = fa.apply(SPECIES.length());
5070         int[] b = fb.apply(SPECIES.length());
5071         int[] c = fc.apply(SPECIES.length());
5072         int[] r = fr.apply(SPECIES.length());
5073 
5074         for (int i = 0; i < a.length; i += SPECIES.length()) {
5075             IntVector av = IntVector.fromArray(SPECIES, a, i);
5076             IntVector bv = IntVector.fromArray(SPECIES, b, i);
5077             av.bitwiseBlend(bv, c[i]).intoArray(r, i);
5078         }
5079         assertBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend);
5080     }
5081 
5082     @Test(dataProvider = "intTernaryOpProvider")
5083     static void bitwiseBlendIntMaxVectorTestsAltBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5084         int[] a = fa.apply(SPECIES.length());
5085         int[] b = fb.apply(SPECIES.length());
5086         int[] c = fc.apply(SPECIES.length());
5087         int[] r = fr.apply(SPECIES.length());
5088 
5089         for (int i = 0; i < a.length; i += SPECIES.length()) {
5090             IntVector av = IntVector.fromArray(SPECIES, a, i);
5091             IntVector cv = IntVector.fromArray(SPECIES, c, i);
5092             av.bitwiseBlend(b[i], cv).intoArray(r, i);
5093         }
5094         assertAltBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend);
5095     }
5096 
5097 
5098     @Test(dataProvider = "intTernaryOpMaskProvider")
5099     static void BITWISE_BLENDIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
5100                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
5101         int[] a = fa.apply(SPECIES.length());
5102         int[] b = fb.apply(SPECIES.length());
5103         int[] c = fc.apply(SPECIES.length());
5104         int[] r = fr.apply(SPECIES.length());
5105         boolean[] mask = fm.apply(SPECIES.length());
5106         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5107 
5108         for (int i = 0; i < a.length; i += SPECIES.length()) {
5109             IntVector av = IntVector.fromArray(SPECIES, a, i);
5110             IntVector bv = IntVector.fromArray(SPECIES, b, i);
5111             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
5112         }
5113 
5114         assertBroadcastArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND);
5115     }
5116 
5117     @Test(dataProvider = "intTernaryOpMaskProvider")
5118     static void BITWISE_BLENDIntMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
5119                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
5120         int[] a = fa.apply(SPECIES.length());
5121         int[] b = fb.apply(SPECIES.length());
5122         int[] c = fc.apply(SPECIES.length());
5123         int[] r = fr.apply(SPECIES.length());
5124         boolean[] mask = fm.apply(SPECIES.length());
5125         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5126 
5127         for (int i = 0; i < a.length; i += SPECIES.length()) {
5128             IntVector av = IntVector.fromArray(SPECIES, a, i);
5129             IntVector cv = IntVector.fromArray(SPECIES, c, i);
5130             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
5131         }
5132 
5133         assertAltBroadcastArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND);
5134     }
5135 
5136 
5137 
5138 
5139     @Test(dataProvider = "intTernaryOpProvider")
5140     static void BITWISE_BLENDIntMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5141         int[] a = fa.apply(SPECIES.length());
5142         int[] b = fb.apply(SPECIES.length());
5143         int[] c = fc.apply(SPECIES.length());
5144         int[] r = fr.apply(SPECIES.length());
5145 
5146         for (int i = 0; i < a.length; i += SPECIES.length()) {
5147             IntVector av = IntVector.fromArray(SPECIES, a, i);
5148             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
5149         }
5150 
5151         assertDoubleBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND);
5152     }

5153     @Test(dataProvider = "intTernaryOpProvider")
5154     static void bitwiseBlendIntMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5155         int[] a = fa.apply(SPECIES.length());
5156         int[] b = fb.apply(SPECIES.length());
5157         int[] c = fc.apply(SPECIES.length());
5158         int[] r = fr.apply(SPECIES.length());
5159 
5160         for (int i = 0; i < a.length; i += SPECIES.length()) {
5161             IntVector av = IntVector.fromArray(SPECIES, a, i);
5162             av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
5163         }
5164 
5165         assertDoubleBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend);
5166     }
5167 
5168 
5169     @Test(dataProvider = "intTernaryOpMaskProvider")
5170     static void BITWISE_BLENDIntMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
5171                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
5172         int[] a = fa.apply(SPECIES.length());
5173         int[] b = fb.apply(SPECIES.length());
5174         int[] c = fc.apply(SPECIES.length());
5175         int[] r = fr.apply(SPECIES.length());
5176         boolean[] mask = fm.apply(SPECIES.length());
5177         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5178 
5179         for (int i = 0; i < a.length; i += SPECIES.length()) {
5180             IntVector av = IntVector.fromArray(SPECIES, a, i);
5181             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
5182         }
5183 
5184         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND);
5185     }
5186 
5187 
5188     static int NEG(int a) {
5189         return (int)(-((int)a));
5190     }
5191 
5192     static int neg(int a) {
5193         return (int)(-((int)a));
5194     }
5195 
5196     @Test(dataProvider = "intUnaryOpProvider")
5197     static void NEGIntMaxVectorTests(IntFunction<int[]> fa) {
5198         int[] a = fa.apply(SPECIES.length());
5199         int[] r = fr.apply(SPECIES.length());
5200 
5201         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5202             for (int i = 0; i < a.length; i += SPECIES.length()) {
5203                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5204                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
5205             }
5206         }
5207 

5280     }
5281 
5282     @Test(dataProvider = "intUnaryOpMaskProvider")
5283     static void ABSMaskedIntMaxVectorTests(IntFunction<int[]> fa,
5284                                                 IntFunction<boolean[]> fm) {
5285         int[] a = fa.apply(SPECIES.length());
5286         int[] r = fr.apply(SPECIES.length());
5287         boolean[] mask = fm.apply(SPECIES.length());
5288         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5289 
5290         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5291             for (int i = 0; i < a.length; i += SPECIES.length()) {
5292                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5293                 av.lanewise(VectorOperators.ABS, vmask).intoArray(r, i);
5294             }
5295         }
5296 
5297         assertArraysEquals(r, a, mask, IntMaxVectorTests::ABS);
5298     }
5299 
5300 
5301     static int NOT(int a) {
5302         return (int)(~((int)a));
5303     }
5304 
5305     static int not(int a) {
5306         return (int)(~((int)a));
5307     }
5308 
5309 
5310 
5311     @Test(dataProvider = "intUnaryOpProvider")
5312     static void NOTIntMaxVectorTests(IntFunction<int[]> fa) {
5313         int[] a = fa.apply(SPECIES.length());
5314         int[] r = fr.apply(SPECIES.length());
5315 
5316         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5317             for (int i = 0; i < a.length; i += SPECIES.length()) {
5318                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5319                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
5320             }
5321         }
5322 
5323         assertArraysEquals(r, a, IntMaxVectorTests::NOT);
5324     }
5325 
5326     @Test(dataProvider = "intUnaryOpProvider")
5327     static void notIntMaxVectorTests(IntFunction<int[]> fa) {
5328         int[] a = fa.apply(SPECIES.length());
5329         int[] r = fr.apply(SPECIES.length());
5330 
5331         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5332             for (int i = 0; i < a.length; i += SPECIES.length()) {
5333                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5334                 av.not().intoArray(r, i);
5335             }
5336         }
5337 
5338         assertArraysEquals(r, a, IntMaxVectorTests::not);
5339     }
5340 
5341 
5342 
5343     @Test(dataProvider = "intUnaryOpMaskProvider")
5344     static void NOTMaskedIntMaxVectorTests(IntFunction<int[]> fa,
5345                                                 IntFunction<boolean[]> fm) {
5346         int[] a = fa.apply(SPECIES.length());
5347         int[] r = fr.apply(SPECIES.length());
5348         boolean[] mask = fm.apply(SPECIES.length());
5349         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5350 
5351         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5352             for (int i = 0; i < a.length; i += SPECIES.length()) {
5353                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5354                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
5355             }
5356         }
5357 
5358         assertArraysEquals(r, a, mask, IntMaxVectorTests::NOT);
5359     }
5360 
5361 
5362 
5363     static int ZOMO(int a) {
5364         return (int)((a==0?0:-1));
5365     }
5366 
5367 
5368 
5369     @Test(dataProvider = "intUnaryOpProvider")
5370     static void ZOMOIntMaxVectorTests(IntFunction<int[]> fa) {
5371         int[] a = fa.apply(SPECIES.length());
5372         int[] r = fr.apply(SPECIES.length());
5373 
5374         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5375             for (int i = 0; i < a.length; i += SPECIES.length()) {
5376                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5377                 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
5378             }
5379         }
5380 
5381         assertArraysEquals(r, a, IntMaxVectorTests::ZOMO);
5382     }
5383 
5384 
5385 
5386     @Test(dataProvider = "intUnaryOpMaskProvider")
5387     static void ZOMOMaskedIntMaxVectorTests(IntFunction<int[]> fa,
5388                                                 IntFunction<boolean[]> fm) {
5389         int[] a = fa.apply(SPECIES.length());
5390         int[] r = fr.apply(SPECIES.length());
5391         boolean[] mask = fm.apply(SPECIES.length());
5392         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5393 
5394         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5395             for (int i = 0; i < a.length; i += SPECIES.length()) {
5396                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5397                 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
5398             }
5399         }
5400 
5401         assertArraysEquals(r, a, mask, IntMaxVectorTests::ZOMO);
5402     }
5403 



5404 




5405 









5406 





































































































































































5407 
5408     @Test(dataProvider = "intCompareOpProvider")
5409     static void ltIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
5410         int[] a = fa.apply(SPECIES.length());
5411         int[] b = fb.apply(SPECIES.length());
5412 
5413         for (int i = 0; i < a.length; i += SPECIES.length()) {
5414             IntVector av = IntVector.fromArray(SPECIES, a, i);
5415             VectorMask<Integer> mv = av.lt(b[i]);
5416 
5417             // Check results as part of computation.
5418             for (int j = 0; j < SPECIES.length(); j++) {
5419                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5420             }
5421         }
5422     }
5423 
5424     @Test(dataProvider = "intCompareOpProvider")
5425     static void eqIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
5426         int[] a = fa.apply(SPECIES.length());

5789             }
5790         }
5791         return i - idx;
5792     }
5793 
5794     @Test(dataProvider = "maskProvider")
5795     static void maskFirstTrueIntMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5796         boolean[] a = fa.apply(SPECIES.length());
5797         int[] r = new int[a.length];
5798 
5799         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5800             for (int i = 0; i < a.length; i += SPECIES.length()) {
5801                 var vmask = SPECIES.loadMask(a, i);
5802                 r[i] = vmask.firstTrue();
5803             }
5804         }
5805 
5806         assertMaskReductionArraysEquals(r, a, IntMaxVectorTests::maskFirstTrue);
5807     }
5808 

















5809 
5810     @DataProvider
5811     public static Object[][] offsetProvider() {
5812         return new Object[][]{
5813                 {0},
5814                 {-1},
5815                 {+1},
5816                 {+2},
5817                 {-2},
5818         };
5819     }
5820 
5821     @Test(dataProvider = "offsetProvider")
5822     static void indexInRangeIntMaxVectorTestsSmokeTest(int offset) {
5823         int limit = SPECIES.length() * BUFFER_REPS;
5824         for (int i = 0; i < limit; i += SPECIES.length()) {
5825             var actualMask = SPECIES.indexInRange(i + offset, limit);
5826             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
5827             assert(actualMask.equals(expectedMask));
5828             for (int j = 0; j < SPECIES.length(); j++)  {
5829                 int index = i + j + offset;
5830                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
5831             }
5832         }
5833     }
5834 














5835     @DataProvider
5836     public static Object[][] lengthProvider() {
5837         return new Object[][]{
5838                 {0},
5839                 {1},
5840                 {32},
5841                 {37},
5842                 {1024},
5843                 {1024+1},
5844                 {1024+5},
5845         };
5846     }
5847 
5848     @Test(dataProvider = "lengthProvider")
5849     static void loopBoundIntMaxVectorTestsSmokeTest(int length) {
5850         int actualLoopBound = SPECIES.loopBound(length);
5851         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
5852         Assert.assertEquals(actualLoopBound, expectedLoopBound);
5853     }
5854 








5855     @Test
5856     static void ElementSizeIntMaxVectorTestsSmokeTest() {
5857         IntVector av = IntVector.zero(SPECIES);
5858         int elsize = av.elementSize();
5859         Assert.assertEquals(elsize, Integer.SIZE);
5860     }
5861 
5862     @Test
5863     static void VectorShapeIntMaxVectorTestsSmokeTest() {
5864         IntVector av = IntVector.zero(SPECIES);
5865         VectorShape vsh = av.shape();
5866         assert(vsh.equals(VectorShape.S_Max_BIT));
5867     }
5868 
5869     @Test
5870     static void ShapeWithLanesIntMaxVectorTestsSmokeTest() {
5871         IntVector av = IntVector.zero(SPECIES);
5872         VectorShape vsh = av.shape();
5873         VectorSpecies species = vsh.withLanes(int.class);
5874         assert(species.equals(SPECIES));

5897         IntVector av = IntVector.zero(SPECIES);
5898         VectorSpecies species = av.species().withLanes(int.class);
5899         assert(species.equals(SPECIES));
5900     }
5901 
5902     @Test
5903     static void WithShapeIntMaxVectorTestsSmokeTest() {
5904         IntVector av = IntVector.zero(SPECIES);
5905         VectorShape vsh = av.shape();
5906         VectorSpecies species = av.species().withShape(vsh);
5907         assert(species.equals(SPECIES));
5908     }
5909 
5910     @Test
5911     static void MaskAllTrueIntMaxVectorTestsSmokeTest() {
5912         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5913           Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
5914         }
5915     }
5916 }
5917 

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

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

 941     static int bits(int e) {
 942         return  e;
 943     }
 944 
 945     static final List<IntFunction<int[]>> INT_GENERATORS = List.of(
 946             withToString("int[-i * 5]", (int s) -> {
 947                 return fill(s * BUFFER_REPS,
 948                             i -> (int)(-i * 5));
 949             }),
 950             withToString("int[i * 5]", (int s) -> {
 951                 return fill(s * BUFFER_REPS,
 952                             i -> (int)(i * 5));
 953             }),
 954             withToString("int[i + 1]", (int s) -> {
 955                 return fill(s * BUFFER_REPS,
 956                             i -> (((int)(i + 1) == 0) ? 1 : (int)(i + 1)));
 957             }),
 958             withToString("int[cornerCaseValue(i)]", (int s) -> {
 959                 return fill(s * BUFFER_REPS,
 960                             i -> cornerCaseValue(i));

1015                 })).
1016                 toArray(Object[][]::new);
1017     }
1018 
1019     @DataProvider
1020     public Object[][] intUnaryOpProvider() {
1021         return INT_GENERATORS.stream().
1022                 map(f -> new Object[]{f}).
1023                 toArray(Object[][]::new);
1024     }
1025 
1026     @DataProvider
1027     public Object[][] intUnaryOpMaskProvider() {
1028         return BOOLEAN_MASK_GENERATORS.stream().
1029                 flatMap(fm -> INT_GENERATORS.stream().map(fa -> {
1030                     return new Object[] {fa, fm};
1031                 })).
1032                 toArray(Object[][]::new);
1033     }
1034 


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

1060 
1061     @DataProvider
1062     public Object[][] intUnaryOpShuffleProvider() {
1063         return INT_SHUFFLE_GENERATORS.stream().
1064                 flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
1065                     return new Object[] {fa, fs};
1066                 })).
1067                 toArray(Object[][]::new);
1068     }
1069 
1070     @DataProvider
1071     public Object[][] intUnaryOpShuffleMaskProvider() {
1072         return BOOLEAN_MASK_GENERATORS.stream().
1073                 flatMap(fm -> INT_SHUFFLE_GENERATORS.stream().
1074                     flatMap(fs -> INT_GENERATORS.stream().map(fa -> {
1075                         return new Object[] {fa, fs, fm};
1076                 }))).
1077                 toArray(Object[][]::new);
1078     }
1079 

1080     static final List<IntFunction<int[]>> INT_COMPARE_GENERATORS = List.of(
1081             withToString("int[i]", (int s) -> {
1082                 return fill(s * BUFFER_REPS,
1083                             i -> (int)i);
1084             }),
1085             withToString("int[i - length / 2]", (int s) -> {
1086                 return fill(s * BUFFER_REPS,
1087                             i -> (int)(i - (s * BUFFER_REPS / 2)));
1088             }),
1089             withToString("int[i + 1]", (int s) -> {
1090                 return fill(s * BUFFER_REPS,
1091                             i -> (int)(i + 1));
1092             }),
1093             withToString("int[i - 2]", (int s) -> {
1094                 return fill(s * BUFFER_REPS,
1095                             i -> (int)(i - 2));
1096             }),
1097             withToString("int[zigZag(i)]", (int s) -> {
1098                 return fill(s * BUFFER_REPS,
1099                             i -> i%3 == 0 ? (int)i : (i%3 == 1 ? (int)(i + 1) : (int)(i - 2)));

1200             }
1201         }
1202     }
1203 
1204     static void replaceZero(int[] a, boolean[] mask, int v) {
1205         for (int i = 0; i < a.length; i++) {
1206             if (mask[i % mask.length] && a[i] == 0) {
1207                 a[i] = v;
1208             }
1209         }
1210     }
1211 
1212     static int ROL_scalar(int a, int b) {
1213         return Integer.rotateLeft(a, ((int)b));
1214     }
1215 
1216     static int ROR_scalar(int a, int b) {
1217         return Integer.rotateRight(a, ((int)b));
1218     }
1219 
1220     static int TRAILING_ZEROS_COUNT_scalar(int a) {
1221         return Integer.numberOfTrailingZeros(a);
1222     }
1223 
1224     static int LEADING_ZEROS_COUNT_scalar(int a) {
1225         return Integer.numberOfLeadingZeros(a);
1226     }
1227 
1228     static int REVERSE_scalar(int a) {
1229         return Integer.reverse(a);
1230     }
1231 
1232     static boolean eq(int a, int b) {
1233         return a == b;
1234     }
1235 
1236     static boolean neq(int a, int b) {
1237         return a != b;
1238     }
1239 
1240     static boolean lt(int a, int b) {
1241         return a < b;
1242     }
1243 
1244     static boolean le(int a, int b) {
1245         return a <= b;
1246     }
1247 
1248     static boolean gt(int a, int b) {
1249         return a > b;
1250     }
1251 

1366     @Test
1367     // Test div by 0.
1368     static void bitwiseDivByZeroSmokeTest() {
1369         try {
1370             IntVector a = (IntVector) SPECIES.broadcast(0).addIndex(1);
1371             IntVector b = (IntVector) SPECIES.broadcast(0);
1372             a.div(b);
1373             Assert.fail();
1374         } catch (ArithmeticException e) {
1375         }
1376 
1377         try {
1378             IntVector a = (IntVector) SPECIES.broadcast(0).addIndex(1);
1379             IntVector b = (IntVector) SPECIES.broadcast(0);
1380             VectorMask<Integer> m = a.lt((int) 1);
1381             a.div(b, m);
1382             Assert.fail();
1383         } catch (ArithmeticException e) {
1384         }
1385     }
1386 
1387     static int ADD(int a, int b) {
1388         return (int)(a + b);
1389     }
1390 
1391     @Test(dataProvider = "intBinaryOpProvider")
1392     static void ADDIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1393         int[] a = fa.apply(SPECIES.length());
1394         int[] b = fb.apply(SPECIES.length());
1395         int[] r = fr.apply(SPECIES.length());
1396 
1397         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1398             for (int i = 0; i < a.length; i += SPECIES.length()) {
1399                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1400                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1401                 av.lanewise(VectorOperators.ADD, bv).intoArray(r, i);
1402             }
1403         }
1404 
1405         assertArraysEquals(r, a, b, IntMaxVectorTests::ADD);
1406     }
1407 
1408     static int add(int a, int b) {
1409         return (int)(a + b);
1410     }
1411 
1412     @Test(dataProvider = "intBinaryOpProvider")
1413     static void addIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1414         int[] a = fa.apply(SPECIES.length());
1415         int[] b = fb.apply(SPECIES.length());
1416         int[] r = fr.apply(SPECIES.length());
1417 
1418         for (int i = 0; i < a.length; i += SPECIES.length()) {
1419             IntVector av = IntVector.fromArray(SPECIES, a, i);
1420             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1421             av.add(bv).intoArray(r, i);
1422         }
1423 
1424         assertArraysEquals(r, a, b, IntMaxVectorTests::add);
1425     }
1426 
1427     @Test(dataProvider = "intBinaryOpMaskProvider")

1444         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ADD);
1445     }
1446 
1447     @Test(dataProvider = "intBinaryOpMaskProvider")
1448     static void addIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1449                                           IntFunction<boolean[]> fm) {
1450         int[] a = fa.apply(SPECIES.length());
1451         int[] b = fb.apply(SPECIES.length());
1452         int[] r = fr.apply(SPECIES.length());
1453         boolean[] mask = fm.apply(SPECIES.length());
1454         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1455 
1456         for (int i = 0; i < a.length; i += SPECIES.length()) {
1457             IntVector av = IntVector.fromArray(SPECIES, a, i);
1458             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1459             av.add(bv, vmask).intoArray(r, i);
1460         }
1461 
1462         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::add);
1463     }
1464 
1465     static int SUB(int a, int b) {
1466         return (int)(a - b);
1467     }
1468 
1469     @Test(dataProvider = "intBinaryOpProvider")
1470     static void SUBIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1471         int[] a = fa.apply(SPECIES.length());
1472         int[] b = fb.apply(SPECIES.length());
1473         int[] r = fr.apply(SPECIES.length());
1474 
1475         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1476             for (int i = 0; i < a.length; i += SPECIES.length()) {
1477                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1478                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1479                 av.lanewise(VectorOperators.SUB, bv).intoArray(r, i);
1480             }
1481         }
1482 
1483         assertArraysEquals(r, a, b, IntMaxVectorTests::SUB);
1484     }
1485 
1486     static int sub(int a, int b) {
1487         return (int)(a - b);
1488     }
1489 
1490     @Test(dataProvider = "intBinaryOpProvider")
1491     static void subIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1492         int[] a = fa.apply(SPECIES.length());
1493         int[] b = fb.apply(SPECIES.length());
1494         int[] r = fr.apply(SPECIES.length());
1495 
1496         for (int i = 0; i < a.length; i += SPECIES.length()) {
1497             IntVector av = IntVector.fromArray(SPECIES, a, i);
1498             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1499             av.sub(bv).intoArray(r, i);
1500         }
1501 
1502         assertArraysEquals(r, a, b, IntMaxVectorTests::sub);
1503     }
1504 
1505     @Test(dataProvider = "intBinaryOpMaskProvider")

1522         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SUB);
1523     }
1524 
1525     @Test(dataProvider = "intBinaryOpMaskProvider")
1526     static void subIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1527                                           IntFunction<boolean[]> fm) {
1528         int[] a = fa.apply(SPECIES.length());
1529         int[] b = fb.apply(SPECIES.length());
1530         int[] r = fr.apply(SPECIES.length());
1531         boolean[] mask = fm.apply(SPECIES.length());
1532         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1533 
1534         for (int i = 0; i < a.length; i += SPECIES.length()) {
1535             IntVector av = IntVector.fromArray(SPECIES, a, i);
1536             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1537             av.sub(bv, vmask).intoArray(r, i);
1538         }
1539 
1540         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::sub);
1541     }
1542 
1543     static int MUL(int a, int b) {
1544         return (int)(a * b);
1545     }
1546 
1547     @Test(dataProvider = "intBinaryOpProvider")
1548     static void MULIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1549         int[] a = fa.apply(SPECIES.length());
1550         int[] b = fb.apply(SPECIES.length());
1551         int[] r = fr.apply(SPECIES.length());
1552 
1553         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1554             for (int i = 0; i < a.length; i += SPECIES.length()) {
1555                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1556                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1557                 av.lanewise(VectorOperators.MUL, bv).intoArray(r, i);
1558             }
1559         }
1560 
1561         assertArraysEquals(r, a, b, IntMaxVectorTests::MUL);
1562     }
1563 
1564     static int mul(int a, int b) {
1565         return (int)(a * b);
1566     }
1567 
1568     @Test(dataProvider = "intBinaryOpProvider")
1569     static void mulIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1570         int[] a = fa.apply(SPECIES.length());
1571         int[] b = fb.apply(SPECIES.length());
1572         int[] r = fr.apply(SPECIES.length());
1573 
1574         for (int i = 0; i < a.length; i += SPECIES.length()) {
1575             IntVector av = IntVector.fromArray(SPECIES, a, i);
1576             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1577             av.mul(bv).intoArray(r, i);
1578         }
1579 
1580         assertArraysEquals(r, a, b, IntMaxVectorTests::mul);
1581     }
1582 
1583     @Test(dataProvider = "intBinaryOpMaskProvider")

1601     }
1602 
1603     @Test(dataProvider = "intBinaryOpMaskProvider")
1604     static void mulIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1605                                           IntFunction<boolean[]> fm) {
1606         int[] a = fa.apply(SPECIES.length());
1607         int[] b = fb.apply(SPECIES.length());
1608         int[] r = fr.apply(SPECIES.length());
1609         boolean[] mask = fm.apply(SPECIES.length());
1610         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1611 
1612         for (int i = 0; i < a.length; i += SPECIES.length()) {
1613             IntVector av = IntVector.fromArray(SPECIES, a, i);
1614             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1615             av.mul(bv, vmask).intoArray(r, i);
1616         }
1617 
1618         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::mul);
1619     }
1620 


1621     static int DIV(int a, int b) {
1622         return (int)(a / b);
1623     }
1624 
1625     @Test(dataProvider = "intBinaryOpProvider")
1626     static void DIVIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1627         int[] a = fa.apply(SPECIES.length());
1628         int[] b = fb.apply(SPECIES.length());
1629         int[] r = fr.apply(SPECIES.length());
1630 
1631         replaceZero(b, (int) 1);
1632 
1633         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1634             for (int i = 0; i < a.length; i += SPECIES.length()) {
1635                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1636                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1637                 av.lanewise(VectorOperators.DIV, bv).intoArray(r, i);
1638             }
1639         }
1640 
1641         assertArraysEquals(r, a, b, IntMaxVectorTests::DIV);
1642     }
1643 
1644     static int div(int a, int b) {
1645         return (int)(a / b);
1646     }
1647 
1648     @Test(dataProvider = "intBinaryOpProvider")
1649     static void divIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1650         int[] a = fa.apply(SPECIES.length());
1651         int[] b = fb.apply(SPECIES.length());
1652         int[] r = fr.apply(SPECIES.length());
1653 
1654         replaceZero(b, (int) 1);
1655 
1656         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1657             for (int i = 0; i < a.length; i += SPECIES.length()) {
1658                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1659                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1660                 av.div(bv).intoArray(r, i);
1661             }
1662         }
1663 
1664         assertArraysEquals(r, a, b, IntMaxVectorTests::div);
1665     }
1666 


1667     @Test(dataProvider = "intBinaryOpMaskProvider")
1668     static void DIVIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1669                                           IntFunction<boolean[]> fm) {
1670         int[] a = fa.apply(SPECIES.length());
1671         int[] b = fb.apply(SPECIES.length());
1672         int[] r = fr.apply(SPECIES.length());
1673         boolean[] mask = fm.apply(SPECIES.length());
1674         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1675 
1676         replaceZero(b, mask, (int) 1);
1677 
1678         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1679             for (int i = 0; i < a.length; i += SPECIES.length()) {
1680                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1681                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1682                 av.lanewise(VectorOperators.DIV, bv, vmask).intoArray(r, i);
1683             }
1684         }
1685 
1686         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::DIV);

1752     static int AND(int a, int b) {
1753         return (int)(a & b);
1754     }
1755 
1756     @Test(dataProvider = "intBinaryOpProvider")
1757     static void ANDIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1758         int[] a = fa.apply(SPECIES.length());
1759         int[] b = fb.apply(SPECIES.length());
1760         int[] r = fr.apply(SPECIES.length());
1761 
1762         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1763             for (int i = 0; i < a.length; i += SPECIES.length()) {
1764                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1765                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1766                 av.lanewise(VectorOperators.AND, bv).intoArray(r, i);
1767             }
1768         }
1769 
1770         assertArraysEquals(r, a, b, IntMaxVectorTests::AND);
1771     }
1772 
1773     static int and(int a, int b) {
1774         return (int)(a & b);
1775     }
1776 
1777     @Test(dataProvider = "intBinaryOpProvider")
1778     static void andIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1779         int[] a = fa.apply(SPECIES.length());
1780         int[] b = fb.apply(SPECIES.length());
1781         int[] r = fr.apply(SPECIES.length());
1782 
1783         for (int i = 0; i < a.length; i += SPECIES.length()) {
1784             IntVector av = IntVector.fromArray(SPECIES, a, i);
1785             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1786             av.and(bv).intoArray(r, i);
1787         }
1788 
1789         assertArraysEquals(r, a, b, IntMaxVectorTests::and);
1790     }
1791 


1792     @Test(dataProvider = "intBinaryOpMaskProvider")
1793     static void ANDIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1794                                           IntFunction<boolean[]> fm) {
1795         int[] a = fa.apply(SPECIES.length());
1796         int[] b = fb.apply(SPECIES.length());
1797         int[] r = fr.apply(SPECIES.length());
1798         boolean[] mask = fm.apply(SPECIES.length());
1799         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1800 
1801         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1802             for (int i = 0; i < a.length; i += SPECIES.length()) {
1803                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1804                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1805                 av.lanewise(VectorOperators.AND, bv, vmask).intoArray(r, i);
1806             }
1807         }
1808 
1809         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::AND);
1810     }
1811 

1812     static int AND_NOT(int a, int b) {
1813         return (int)(a & ~b);
1814     }
1815 
1816     @Test(dataProvider = "intBinaryOpProvider")
1817     static void AND_NOTIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1818         int[] a = fa.apply(SPECIES.length());
1819         int[] b = fb.apply(SPECIES.length());
1820         int[] r = fr.apply(SPECIES.length());
1821 
1822         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1823             for (int i = 0; i < a.length; i += SPECIES.length()) {
1824                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1825                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1826                 av.lanewise(VectorOperators.AND_NOT, bv).intoArray(r, i);
1827             }
1828         }
1829 
1830         assertArraysEquals(r, a, b, IntMaxVectorTests::AND_NOT);
1831     }
1832 


1833     @Test(dataProvider = "intBinaryOpMaskProvider")
1834     static void AND_NOTIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1835                                           IntFunction<boolean[]> fm) {
1836         int[] a = fa.apply(SPECIES.length());
1837         int[] b = fb.apply(SPECIES.length());
1838         int[] r = fr.apply(SPECIES.length());
1839         boolean[] mask = fm.apply(SPECIES.length());
1840         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1841 
1842         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1843             for (int i = 0; i < a.length; i += SPECIES.length()) {
1844                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1845                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1846                 av.lanewise(VectorOperators.AND_NOT, bv, vmask).intoArray(r, i);
1847             }
1848         }
1849 
1850         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::AND_NOT);
1851     }
1852 

1853     static int OR(int a, int b) {
1854         return (int)(a | b);
1855     }
1856 
1857     @Test(dataProvider = "intBinaryOpProvider")
1858     static void ORIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1859         int[] a = fa.apply(SPECIES.length());
1860         int[] b = fb.apply(SPECIES.length());
1861         int[] r = fr.apply(SPECIES.length());
1862 
1863         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1864             for (int i = 0; i < a.length; i += SPECIES.length()) {
1865                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1866                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1867                 av.lanewise(VectorOperators.OR, bv).intoArray(r, i);
1868             }
1869         }
1870 
1871         assertArraysEquals(r, a, b, IntMaxVectorTests::OR);
1872     }
1873 
1874     static int or(int a, int b) {
1875         return (int)(a | b);
1876     }
1877 
1878     @Test(dataProvider = "intBinaryOpProvider")
1879     static void orIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1880         int[] a = fa.apply(SPECIES.length());
1881         int[] b = fb.apply(SPECIES.length());
1882         int[] r = fr.apply(SPECIES.length());
1883 
1884         for (int i = 0; i < a.length; i += SPECIES.length()) {
1885             IntVector av = IntVector.fromArray(SPECIES, a, i);
1886             IntVector bv = IntVector.fromArray(SPECIES, b, i);
1887             av.or(bv).intoArray(r, i);
1888         }
1889 
1890         assertArraysEquals(r, a, b, IntMaxVectorTests::or);
1891     }
1892 


1893     @Test(dataProvider = "intBinaryOpMaskProvider")
1894     static void ORIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1895                                           IntFunction<boolean[]> fm) {
1896         int[] a = fa.apply(SPECIES.length());
1897         int[] b = fb.apply(SPECIES.length());
1898         int[] r = fr.apply(SPECIES.length());
1899         boolean[] mask = fm.apply(SPECIES.length());
1900         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1901 
1902         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1903             for (int i = 0; i < a.length; i += SPECIES.length()) {
1904                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1905                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1906                 av.lanewise(VectorOperators.OR, bv, vmask).intoArray(r, i);
1907             }
1908         }
1909 
1910         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::OR);
1911     }
1912 

1913     static int XOR(int a, int b) {
1914         return (int)(a ^ b);
1915     }
1916 
1917     @Test(dataProvider = "intBinaryOpProvider")
1918     static void XORIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1919         int[] a = fa.apply(SPECIES.length());
1920         int[] b = fb.apply(SPECIES.length());
1921         int[] r = fr.apply(SPECIES.length());
1922 
1923         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1924             for (int i = 0; i < a.length; i += SPECIES.length()) {
1925                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1926                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1927                 av.lanewise(VectorOperators.XOR, bv).intoArray(r, i);
1928             }
1929         }
1930 
1931         assertArraysEquals(r, a, b, IntMaxVectorTests::XOR);
1932     }
1933 


1934     @Test(dataProvider = "intBinaryOpMaskProvider")
1935     static void XORIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1936                                           IntFunction<boolean[]> fm) {
1937         int[] a = fa.apply(SPECIES.length());
1938         int[] b = fb.apply(SPECIES.length());
1939         int[] r = fr.apply(SPECIES.length());
1940         boolean[] mask = fm.apply(SPECIES.length());
1941         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1942 
1943         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1944             for (int i = 0; i < a.length; i += SPECIES.length()) {
1945                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1946                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1947                 av.lanewise(VectorOperators.XOR, bv, vmask).intoArray(r, i);
1948             }
1949         }
1950 
1951         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::XOR);
1952     }
1953 
1954     static int COMPRESS_BITS(int a, int b) {
1955         return (int)(Integer.compress(a, b));
1956     }
1957 
1958     @Test(dataProvider = "intBinaryOpProvider")
1959     static void COMPRESS_BITSIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
1960         int[] a = fa.apply(SPECIES.length());
1961         int[] b = fb.apply(SPECIES.length());
1962         int[] r = fr.apply(SPECIES.length());
1963 
1964         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1965             for (int i = 0; i < a.length; i += SPECIES.length()) {
1966                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1967                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1968                 av.lanewise(VectorOperators.COMPRESS_BITS, bv).intoArray(r, i);
1969             }
1970         }
1971 
1972         assertArraysEquals(r, a, b, IntMaxVectorTests::COMPRESS_BITS);
1973     }
1974 
1975     @Test(dataProvider = "intBinaryOpMaskProvider")
1976     static void COMPRESS_BITSIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
1977                                           IntFunction<boolean[]> fm) {
1978         int[] a = fa.apply(SPECIES.length());
1979         int[] b = fb.apply(SPECIES.length());
1980         int[] r = fr.apply(SPECIES.length());
1981         boolean[] mask = fm.apply(SPECIES.length());
1982         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
1983 
1984         for (int ic = 0; ic < INVOC_COUNT; ic++) {
1985             for (int i = 0; i < a.length; i += SPECIES.length()) {
1986                 IntVector av = IntVector.fromArray(SPECIES, a, i);
1987                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
1988                 av.lanewise(VectorOperators.COMPRESS_BITS, bv, vmask).intoArray(r, i);
1989             }
1990         }
1991 
1992         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::COMPRESS_BITS);
1993     }
1994 
1995     static int EXPAND_BITS(int a, int b) {
1996         return (int)(Integer.expand(a, b));
1997     }
1998 
1999     @Test(dataProvider = "intBinaryOpProvider")
2000     static void EXPAND_BITSIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2001         int[] a = fa.apply(SPECIES.length());
2002         int[] b = fb.apply(SPECIES.length());
2003         int[] r = fr.apply(SPECIES.length());
2004 
2005         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2006             for (int i = 0; i < a.length; i += SPECIES.length()) {
2007                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2008                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2009                 av.lanewise(VectorOperators.EXPAND_BITS, bv).intoArray(r, i);
2010             }
2011         }
2012 
2013         assertArraysEquals(r, a, b, IntMaxVectorTests::EXPAND_BITS);
2014     }
2015 
2016     @Test(dataProvider = "intBinaryOpMaskProvider")
2017     static void EXPAND_BITSIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2018                                           IntFunction<boolean[]> fm) {
2019         int[] a = fa.apply(SPECIES.length());
2020         int[] b = fb.apply(SPECIES.length());
2021         int[] r = fr.apply(SPECIES.length());
2022         boolean[] mask = fm.apply(SPECIES.length());
2023         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2024 
2025         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2026             for (int i = 0; i < a.length; i += SPECIES.length()) {
2027                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2028                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2029                 av.lanewise(VectorOperators.EXPAND_BITS, bv, vmask).intoArray(r, i);
2030             }
2031         }
2032 
2033         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::EXPAND_BITS);
2034     }
2035 
2036     @Test(dataProvider = "intBinaryOpProvider")
2037     static void addIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2038         int[] a = fa.apply(SPECIES.length());
2039         int[] b = fb.apply(SPECIES.length());
2040         int[] r = fr.apply(SPECIES.length());
2041 
2042         for (int i = 0; i < a.length; i += SPECIES.length()) {
2043             IntVector av = IntVector.fromArray(SPECIES, a, i);
2044             av.add(b[i]).intoArray(r, i);
2045         }
2046 
2047         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::add);
2048     }
2049 
2050     @Test(dataProvider = "intBinaryOpMaskProvider")
2051     static void addIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2052                                           IntFunction<boolean[]> fm) {
2053         int[] a = fa.apply(SPECIES.length());
2054         int[] b = fb.apply(SPECIES.length());

2109         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::mul);
2110     }
2111 
2112     @Test(dataProvider = "intBinaryOpMaskProvider")
2113     static void mulIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2114                                           IntFunction<boolean[]> fm) {
2115         int[] a = fa.apply(SPECIES.length());
2116         int[] b = fb.apply(SPECIES.length());
2117         int[] r = fr.apply(SPECIES.length());
2118         boolean[] mask = fm.apply(SPECIES.length());
2119         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2120 
2121         for (int i = 0; i < a.length; i += SPECIES.length()) {
2122             IntVector av = IntVector.fromArray(SPECIES, a, i);
2123             av.mul(b[i], vmask).intoArray(r, i);
2124         }
2125 
2126         assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::mul);
2127     }
2128 



2129     @Test(dataProvider = "intBinaryOpProvider")
2130     static void divIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2131         int[] a = fa.apply(SPECIES.length());
2132         int[] b = fb.apply(SPECIES.length());
2133         int[] r = fr.apply(SPECIES.length());
2134 
2135         replaceZero(b, (int) 1);
2136 
2137         for (int i = 0; i < a.length; i += SPECIES.length()) {
2138             IntVector av = IntVector.fromArray(SPECIES, a, i);
2139             av.div(b[i]).intoArray(r, i);
2140         }
2141 
2142         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::div);
2143     }
2144 


2145     @Test(dataProvider = "intBinaryOpMaskProvider")
2146     static void divIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2147                                           IntFunction<boolean[]> fm) {
2148         int[] a = fa.apply(SPECIES.length());
2149         int[] b = fb.apply(SPECIES.length());
2150         int[] r = fr.apply(SPECIES.length());
2151         boolean[] mask = fm.apply(SPECIES.length());
2152         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2153 
2154         replaceZero(b, (int) 1);
2155 
2156         for (int i = 0; i < a.length; i += SPECIES.length()) {
2157             IntVector av = IntVector.fromArray(SPECIES, a, i);
2158             av.div(b[i], vmask).intoArray(r, i);
2159         }
2160 
2161         assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::div);
2162     }
2163 


2164     @Test(dataProvider = "intBinaryOpProvider")
2165     static void ORIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2166         int[] a = fa.apply(SPECIES.length());
2167         int[] b = fb.apply(SPECIES.length());
2168         int[] r = fr.apply(SPECIES.length());
2169 
2170         for (int i = 0; i < a.length; i += SPECIES.length()) {
2171             IntVector av = IntVector.fromArray(SPECIES, a, i);
2172             av.lanewise(VectorOperators.OR, b[i]).intoArray(r, i);
2173         }
2174 
2175         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::OR);
2176     }
2177 
2178     @Test(dataProvider = "intBinaryOpProvider")
2179     static void orIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2180         int[] a = fa.apply(SPECIES.length());
2181         int[] b = fb.apply(SPECIES.length());
2182         int[] r = fr.apply(SPECIES.length());
2183 
2184         for (int i = 0; i < a.length; i += SPECIES.length()) {
2185             IntVector av = IntVector.fromArray(SPECIES, a, i);
2186             av.or(b[i]).intoArray(r, i);
2187         }
2188 
2189         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::or);
2190     }
2191 


2192     @Test(dataProvider = "intBinaryOpMaskProvider")
2193     static void ORIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2194                                           IntFunction<boolean[]> fm) {
2195         int[] a = fa.apply(SPECIES.length());
2196         int[] b = fb.apply(SPECIES.length());
2197         int[] r = fr.apply(SPECIES.length());
2198         boolean[] mask = fm.apply(SPECIES.length());
2199         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2200 
2201         for (int i = 0; i < a.length; i += SPECIES.length()) {
2202             IntVector av = IntVector.fromArray(SPECIES, a, i);
2203             av.lanewise(VectorOperators.OR, b[i], vmask).intoArray(r, i);
2204         }
2205 
2206         assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::OR);
2207     }
2208 


2209     @Test(dataProvider = "intBinaryOpProvider")
2210     static void ANDIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2211         int[] a = fa.apply(SPECIES.length());
2212         int[] b = fb.apply(SPECIES.length());
2213         int[] r = fr.apply(SPECIES.length());
2214 
2215         for (int i = 0; i < a.length; i += SPECIES.length()) {
2216             IntVector av = IntVector.fromArray(SPECIES, a, i);
2217             av.lanewise(VectorOperators.AND, b[i]).intoArray(r, i);
2218         }
2219 
2220         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::AND);
2221     }
2222 
2223     @Test(dataProvider = "intBinaryOpProvider")
2224     static void andIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2225         int[] a = fa.apply(SPECIES.length());
2226         int[] b = fb.apply(SPECIES.length());
2227         int[] r = fr.apply(SPECIES.length());
2228 
2229         for (int i = 0; i < a.length; i += SPECIES.length()) {
2230             IntVector av = IntVector.fromArray(SPECIES, a, i);
2231             av.and(b[i]).intoArray(r, i);
2232         }
2233 
2234         assertBroadcastArraysEquals(r, a, b, IntMaxVectorTests::and);
2235     }
2236 


2237     @Test(dataProvider = "intBinaryOpMaskProvider")
2238     static void ANDIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2239                                           IntFunction<boolean[]> fm) {
2240         int[] a = fa.apply(SPECIES.length());
2241         int[] b = fb.apply(SPECIES.length());
2242         int[] r = fr.apply(SPECIES.length());
2243         boolean[] mask = fm.apply(SPECIES.length());
2244         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2245 
2246         for (int i = 0; i < a.length; i += SPECIES.length()) {
2247             IntVector av = IntVector.fromArray(SPECIES, a, i);
2248             av.lanewise(VectorOperators.AND, b[i], vmask).intoArray(r, i);
2249         }
2250 
2251         assertBroadcastArraysEquals(r, a, b, mask, IntMaxVectorTests::AND);
2252     }
2253 


2254     @Test(dataProvider = "intBinaryOpProvider")
2255     static void ORIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2256         int[] a = fa.apply(SPECIES.length());
2257         int[] b = fb.apply(SPECIES.length());
2258         int[] r = fr.apply(SPECIES.length());
2259 
2260         for (int i = 0; i < a.length; i += SPECIES.length()) {
2261             IntVector av = IntVector.fromArray(SPECIES, a, i);
2262             av.lanewise(VectorOperators.OR, (long)b[i]).intoArray(r, i);
2263         }
2264 
2265         assertBroadcastLongArraysEquals(r, a, b, IntMaxVectorTests::OR);
2266     }
2267 


2268     @Test(dataProvider = "intBinaryOpMaskProvider")
2269     static void ORIntMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2270                                           IntFunction<boolean[]> fm) {
2271         int[] a = fa.apply(SPECIES.length());
2272         int[] b = fb.apply(SPECIES.length());
2273         int[] r = fr.apply(SPECIES.length());
2274         boolean[] mask = fm.apply(SPECIES.length());
2275         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2276 
2277         for (int i = 0; i < a.length; i += SPECIES.length()) {
2278             IntVector av = IntVector.fromArray(SPECIES, a, i);
2279             av.lanewise(VectorOperators.OR, (long)b[i], vmask).intoArray(r, i);
2280         }
2281 
2282         assertBroadcastLongArraysEquals(r, a, b, mask, IntMaxVectorTests::OR);
2283     }
2284 

2285     @Test(dataProvider = "intBinaryOpProvider")
2286     static void ADDIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2287         int[] a = fa.apply(SPECIES.length());
2288         int[] b = fb.apply(SPECIES.length());
2289         int[] r = fr.apply(SPECIES.length());
2290 
2291         for (int i = 0; i < a.length; i += SPECIES.length()) {
2292             IntVector av = IntVector.fromArray(SPECIES, a, i);
2293             av.lanewise(VectorOperators.ADD, (long)b[i]).intoArray(r, i);
2294         }
2295 
2296         assertBroadcastLongArraysEquals(r, a, b, IntMaxVectorTests::ADD);
2297     }
2298 
2299     @Test(dataProvider = "intBinaryOpMaskProvider")
2300     static void ADDIntMaxVectorTestsBroadcastMaskedLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
2301                                           IntFunction<boolean[]> fm) {
2302         int[] a = fa.apply(SPECIES.length());
2303         int[] b = fb.apply(SPECIES.length());
2304         int[] r = fr.apply(SPECIES.length());

2317         return (int)((a << b));
2318     }
2319 
2320     @Test(dataProvider = "intBinaryOpProvider")
2321     static void LSHLIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2322         int[] a = fa.apply(SPECIES.length());
2323         int[] b = fb.apply(SPECIES.length());
2324         int[] r = fr.apply(SPECIES.length());
2325 
2326         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2327             for (int i = 0; i < a.length; i += SPECIES.length()) {
2328                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2329                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2330                 av.lanewise(VectorOperators.LSHL, bv).intoArray(r, i);
2331             }
2332         }
2333 
2334         assertArraysEquals(r, a, b, IntMaxVectorTests::LSHL);
2335     }
2336 


2337     @Test(dataProvider = "intBinaryOpMaskProvider")
2338     static void LSHLIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2339                                           IntFunction<boolean[]> fm) {
2340         int[] a = fa.apply(SPECIES.length());
2341         int[] b = fb.apply(SPECIES.length());
2342         int[] r = fr.apply(SPECIES.length());
2343         boolean[] mask = fm.apply(SPECIES.length());
2344         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2345 
2346         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2347             for (int i = 0; i < a.length; i += SPECIES.length()) {
2348                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2349                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2350                 av.lanewise(VectorOperators.LSHL, bv, vmask).intoArray(r, i);
2351             }
2352         }
2353 
2354         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHL);
2355     }
2356 





2357     static int ASHR(int a, int b) {
2358         return (int)((a >> b));
2359     }
2360 
2361     @Test(dataProvider = "intBinaryOpProvider")
2362     static void ASHRIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2363         int[] a = fa.apply(SPECIES.length());
2364         int[] b = fb.apply(SPECIES.length());
2365         int[] r = fr.apply(SPECIES.length());
2366 
2367         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2368             for (int i = 0; i < a.length; i += SPECIES.length()) {
2369                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2370                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2371                 av.lanewise(VectorOperators.ASHR, bv).intoArray(r, i);
2372             }
2373         }
2374 
2375         assertArraysEquals(r, a, b, IntMaxVectorTests::ASHR);
2376     }
2377 


2378     @Test(dataProvider = "intBinaryOpMaskProvider")
2379     static void ASHRIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2380                                           IntFunction<boolean[]> fm) {
2381         int[] a = fa.apply(SPECIES.length());
2382         int[] b = fb.apply(SPECIES.length());
2383         int[] r = fr.apply(SPECIES.length());
2384         boolean[] mask = fm.apply(SPECIES.length());
2385         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2386 
2387         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2388             for (int i = 0; i < a.length; i += SPECIES.length()) {
2389                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2390                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2391                 av.lanewise(VectorOperators.ASHR, bv, vmask).intoArray(r, i);
2392             }
2393         }
2394 
2395         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ASHR);
2396     }
2397 





2398     static int LSHR(int a, int b) {
2399         return (int)((a >>> b));
2400     }
2401 
2402     @Test(dataProvider = "intBinaryOpProvider")
2403     static void LSHRIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2404         int[] a = fa.apply(SPECIES.length());
2405         int[] b = fb.apply(SPECIES.length());
2406         int[] r = fr.apply(SPECIES.length());
2407 
2408         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2409             for (int i = 0; i < a.length; i += SPECIES.length()) {
2410                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2411                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2412                 av.lanewise(VectorOperators.LSHR, bv).intoArray(r, i);
2413             }
2414         }
2415 
2416         assertArraysEquals(r, a, b, IntMaxVectorTests::LSHR);
2417     }
2418 


2419     @Test(dataProvider = "intBinaryOpMaskProvider")
2420     static void LSHRIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2421                                           IntFunction<boolean[]> fm) {
2422         int[] a = fa.apply(SPECIES.length());
2423         int[] b = fb.apply(SPECIES.length());
2424         int[] r = fr.apply(SPECIES.length());
2425         boolean[] mask = fm.apply(SPECIES.length());
2426         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2427 
2428         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2429             for (int i = 0; i < a.length; i += SPECIES.length()) {
2430                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2431                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2432                 av.lanewise(VectorOperators.LSHR, bv, vmask).intoArray(r, i);
2433             }
2434         }
2435 
2436         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHR);
2437     }
2438 





2439     static int LSHL_unary(int a, int b) {
2440         return (int)((a << b));
2441     }
2442 
2443     @Test(dataProvider = "intBinaryOpProvider")
2444     static void LSHLIntMaxVectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2445         int[] a = fa.apply(SPECIES.length());
2446         int[] b = fb.apply(SPECIES.length());
2447         int[] r = fr.apply(SPECIES.length());
2448 
2449         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2450             for (int i = 0; i < a.length; i += SPECIES.length()) {
2451                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2452                 av.lanewise(VectorOperators.LSHL, (int)b[i]).intoArray(r, i);
2453             }
2454         }
2455 
2456         assertShiftArraysEquals(r, a, b, IntMaxVectorTests::LSHL_unary);
2457     }
2458 


2459     @Test(dataProvider = "intBinaryOpMaskProvider")
2460     static void LSHLIntMaxVectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2461                                           IntFunction<boolean[]> fm) {
2462         int[] a = fa.apply(SPECIES.length());
2463         int[] b = fb.apply(SPECIES.length());
2464         int[] r = fr.apply(SPECIES.length());
2465         boolean[] mask = fm.apply(SPECIES.length());
2466         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2467 
2468         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2469             for (int i = 0; i < a.length; i += SPECIES.length()) {
2470                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2471                 av.lanewise(VectorOperators.LSHL, (int)b[i], vmask).intoArray(r, i);
2472             }
2473         }
2474 
2475         assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHL_unary);
2476     }
2477 





2478     static int LSHR_unary(int a, int b) {
2479         return (int)((a >>> b));
2480     }
2481 
2482     @Test(dataProvider = "intBinaryOpProvider")
2483     static void LSHRIntMaxVectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2484         int[] a = fa.apply(SPECIES.length());
2485         int[] b = fb.apply(SPECIES.length());
2486         int[] r = fr.apply(SPECIES.length());
2487 
2488         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2489             for (int i = 0; i < a.length; i += SPECIES.length()) {
2490                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2491                 av.lanewise(VectorOperators.LSHR, (int)b[i]).intoArray(r, i);
2492             }
2493         }
2494 
2495         assertShiftArraysEquals(r, a, b, IntMaxVectorTests::LSHR_unary);
2496     }
2497 


2498     @Test(dataProvider = "intBinaryOpMaskProvider")
2499     static void LSHRIntMaxVectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2500                                           IntFunction<boolean[]> fm) {
2501         int[] a = fa.apply(SPECIES.length());
2502         int[] b = fb.apply(SPECIES.length());
2503         int[] r = fr.apply(SPECIES.length());
2504         boolean[] mask = fm.apply(SPECIES.length());
2505         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2506 
2507         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2508             for (int i = 0; i < a.length; i += SPECIES.length()) {
2509                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2510                 av.lanewise(VectorOperators.LSHR, (int)b[i], vmask).intoArray(r, i);
2511             }
2512         }
2513 
2514         assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::LSHR_unary);
2515     }
2516 





2517     static int ASHR_unary(int a, int b) {
2518         return (int)((a >> b));
2519     }
2520 
2521     @Test(dataProvider = "intBinaryOpProvider")
2522     static void ASHRIntMaxVectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2523         int[] a = fa.apply(SPECIES.length());
2524         int[] b = fb.apply(SPECIES.length());
2525         int[] r = fr.apply(SPECIES.length());
2526 
2527         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2528             for (int i = 0; i < a.length; i += SPECIES.length()) {
2529                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2530                 av.lanewise(VectorOperators.ASHR, (int)b[i]).intoArray(r, i);
2531             }
2532         }
2533 
2534         assertShiftArraysEquals(r, a, b, IntMaxVectorTests::ASHR_unary);
2535     }
2536 


2537     @Test(dataProvider = "intBinaryOpMaskProvider")
2538     static void ASHRIntMaxVectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2539                                           IntFunction<boolean[]> fm) {
2540         int[] a = fa.apply(SPECIES.length());
2541         int[] b = fb.apply(SPECIES.length());
2542         int[] r = fr.apply(SPECIES.length());
2543         boolean[] mask = fm.apply(SPECIES.length());
2544         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2545 
2546         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2547             for (int i = 0; i < a.length; i += SPECIES.length()) {
2548                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2549                 av.lanewise(VectorOperators.ASHR, (int)b[i], vmask).intoArray(r, i);
2550             }
2551         }
2552 
2553         assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::ASHR_unary);
2554     }
2555 





2556     static int ROR(int a, int b) {
2557         return (int)(ROR_scalar(a,b));
2558     }
2559 
2560     @Test(dataProvider = "intBinaryOpProvider")
2561     static void RORIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2562         int[] a = fa.apply(SPECIES.length());
2563         int[] b = fb.apply(SPECIES.length());
2564         int[] r = fr.apply(SPECIES.length());
2565 
2566         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2567             for (int i = 0; i < a.length; i += SPECIES.length()) {
2568                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2569                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2570                 av.lanewise(VectorOperators.ROR, bv).intoArray(r, i);
2571             }
2572         }
2573 
2574         assertArraysEquals(r, a, b, IntMaxVectorTests::ROR);
2575     }
2576 


2577     @Test(dataProvider = "intBinaryOpMaskProvider")
2578     static void RORIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2579                                           IntFunction<boolean[]> fm) {
2580         int[] a = fa.apply(SPECIES.length());
2581         int[] b = fb.apply(SPECIES.length());
2582         int[] r = fr.apply(SPECIES.length());
2583         boolean[] mask = fm.apply(SPECIES.length());
2584         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2585 
2586         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2587             for (int i = 0; i < a.length; i += SPECIES.length()) {
2588                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2589                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2590                 av.lanewise(VectorOperators.ROR, bv, vmask).intoArray(r, i);
2591             }
2592         }
2593 
2594         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ROR);
2595     }
2596 

2597     static int ROL(int a, int b) {
2598         return (int)(ROL_scalar(a,b));
2599     }
2600 
2601     @Test(dataProvider = "intBinaryOpProvider")
2602     static void ROLIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2603         int[] a = fa.apply(SPECIES.length());
2604         int[] b = fb.apply(SPECIES.length());
2605         int[] r = fr.apply(SPECIES.length());
2606 
2607         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2608             for (int i = 0; i < a.length; i += SPECIES.length()) {
2609                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2610                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2611                 av.lanewise(VectorOperators.ROL, bv).intoArray(r, i);
2612             }
2613         }
2614 
2615         assertArraysEquals(r, a, b, IntMaxVectorTests::ROL);
2616     }
2617 


2618     @Test(dataProvider = "intBinaryOpMaskProvider")
2619     static void ROLIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2620                                           IntFunction<boolean[]> fm) {
2621         int[] a = fa.apply(SPECIES.length());
2622         int[] b = fb.apply(SPECIES.length());
2623         int[] r = fr.apply(SPECIES.length());
2624         boolean[] mask = fm.apply(SPECIES.length());
2625         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2626 
2627         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2628             for (int i = 0; i < a.length; i += SPECIES.length()) {
2629                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2630                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2631                 av.lanewise(VectorOperators.ROL, bv, vmask).intoArray(r, i);
2632             }
2633         }
2634 
2635         assertArraysEquals(r, a, b, mask, IntMaxVectorTests::ROL);
2636     }
2637 

2638     static int ROR_unary(int a, int b) {
2639         return (int)(ROR_scalar(a, b));
2640     }
2641 
2642     @Test(dataProvider = "intBinaryOpProvider")
2643     static void RORIntMaxVectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2644         int[] a = fa.apply(SPECIES.length());
2645         int[] b = fb.apply(SPECIES.length());
2646         int[] r = fr.apply(SPECIES.length());
2647 
2648         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2649             for (int i = 0; i < a.length; i += SPECIES.length()) {
2650                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2651                 av.lanewise(VectorOperators.ROR, (int)b[i]).intoArray(r, i);
2652             }
2653         }
2654 
2655         assertShiftArraysEquals(r, a, b, IntMaxVectorTests::ROR_unary);
2656     }
2657 


2658     @Test(dataProvider = "intBinaryOpMaskProvider")
2659     static void RORIntMaxVectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2660                                           IntFunction<boolean[]> fm) {
2661         int[] a = fa.apply(SPECIES.length());
2662         int[] b = fb.apply(SPECIES.length());
2663         int[] r = fr.apply(SPECIES.length());
2664         boolean[] mask = fm.apply(SPECIES.length());
2665         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2666 
2667         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2668             for (int i = 0; i < a.length; i += SPECIES.length()) {
2669                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2670                 av.lanewise(VectorOperators.ROR, (int)b[i], vmask).intoArray(r, i);
2671             }
2672         }
2673 
2674         assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::ROR_unary);
2675     }
2676 

2677     static int ROL_unary(int a, int b) {
2678         return (int)(ROL_scalar(a, b));
2679     }
2680 
2681     @Test(dataProvider = "intBinaryOpProvider")
2682     static void ROLIntMaxVectorTestsScalarShift(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2683         int[] a = fa.apply(SPECIES.length());
2684         int[] b = fb.apply(SPECIES.length());
2685         int[] r = fr.apply(SPECIES.length());
2686 
2687         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2688             for (int i = 0; i < a.length; i += SPECIES.length()) {
2689                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2690                 av.lanewise(VectorOperators.ROL, (int)b[i]).intoArray(r, i);
2691             }
2692         }
2693 
2694         assertShiftArraysEquals(r, a, b, IntMaxVectorTests::ROL_unary);
2695     }
2696 


2697     @Test(dataProvider = "intBinaryOpMaskProvider")
2698     static void ROLIntMaxVectorTestsScalarShiftMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
2699                                           IntFunction<boolean[]> fm) {
2700         int[] a = fa.apply(SPECIES.length());
2701         int[] b = fb.apply(SPECIES.length());
2702         int[] r = fr.apply(SPECIES.length());
2703         boolean[] mask = fm.apply(SPECIES.length());
2704         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2705 
2706         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2707             for (int i = 0; i < a.length; i += SPECIES.length()) {
2708                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2709                 av.lanewise(VectorOperators.ROL, (int)b[i], vmask).intoArray(r, i);
2710             }
2711         }
2712 
2713         assertShiftArraysEquals(r, a, b, mask, IntMaxVectorTests::ROL_unary);
2714     }


2715     static int LSHR_binary_const(int a) {
2716         return (int)((a >>> CONST_SHIFT));
2717     }
2718 
2719     @Test(dataProvider = "intUnaryOpProvider")
2720     static void LSHRIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
2721         int[] a = fa.apply(SPECIES.length());
2722         int[] r = fr.apply(SPECIES.length());
2723 
2724         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2725             for (int i = 0; i < a.length; i += SPECIES.length()) {
2726                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2727                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT).intoArray(r, i);
2728             }
2729         }
2730 
2731         assertShiftConstEquals(r, a, IntMaxVectorTests::LSHR_binary_const);
2732     }
2733 


2734     @Test(dataProvider = "intUnaryOpMaskProvider")
2735     static void LSHRIntMaxVectorTestsScalarShiftMaskedConst(IntFunction<int[]> fa,
2736                                           IntFunction<boolean[]> fm) {
2737         int[] a = fa.apply(SPECIES.length());
2738         int[] r = fr.apply(SPECIES.length());
2739         boolean[] mask = fm.apply(SPECIES.length());
2740         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2741 
2742         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2743             for (int i = 0; i < a.length; i += SPECIES.length()) {
2744                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2745                 av.lanewise(VectorOperators.LSHR, CONST_SHIFT, vmask).intoArray(r, i);
2746             }
2747         }
2748 
2749         assertShiftConstEquals(r, a, mask, IntMaxVectorTests::LSHR_binary_const);
2750     }
2751 






2752     static int LSHL_binary_const(int a) {
2753         return (int)((a << CONST_SHIFT));
2754     }
2755 
2756     @Test(dataProvider = "intUnaryOpProvider")
2757     static void LSHLIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
2758         int[] a = fa.apply(SPECIES.length());
2759         int[] r = fr.apply(SPECIES.length());
2760 
2761         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2762             for (int i = 0; i < a.length; i += SPECIES.length()) {
2763                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2764                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT).intoArray(r, i);
2765             }
2766         }
2767 
2768         assertShiftConstEquals(r, a, IntMaxVectorTests::LSHL_binary_const);
2769     }
2770 


2771     @Test(dataProvider = "intUnaryOpMaskProvider")
2772     static void LSHLIntMaxVectorTestsScalarShiftMaskedConst(IntFunction<int[]> fa,
2773                                           IntFunction<boolean[]> fm) {
2774         int[] a = fa.apply(SPECIES.length());
2775         int[] r = fr.apply(SPECIES.length());
2776         boolean[] mask = fm.apply(SPECIES.length());
2777         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2778 
2779         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2780             for (int i = 0; i < a.length; i += SPECIES.length()) {
2781                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2782                 av.lanewise(VectorOperators.LSHL, CONST_SHIFT, vmask).intoArray(r, i);
2783             }
2784         }
2785 
2786         assertShiftConstEquals(r, a, mask, IntMaxVectorTests::LSHL_binary_const);
2787     }
2788 


2789     static int ASHR_binary_const(int a) {
2790         return (int)((a >> CONST_SHIFT));
2791     }
2792 
2793     @Test(dataProvider = "intUnaryOpProvider")
2794     static void ASHRIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
2795         int[] a = fa.apply(SPECIES.length());
2796         int[] r = fr.apply(SPECIES.length());
2797 
2798         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2799             for (int i = 0; i < a.length; i += SPECIES.length()) {
2800                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2801                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT).intoArray(r, i);
2802             }
2803         }
2804 
2805         assertShiftConstEquals(r, a, IntMaxVectorTests::ASHR_binary_const);
2806     }
2807 


2808     @Test(dataProvider = "intUnaryOpMaskProvider")
2809     static void ASHRIntMaxVectorTestsScalarShiftMaskedConst(IntFunction<int[]> fa,
2810                                           IntFunction<boolean[]> fm) {
2811         int[] a = fa.apply(SPECIES.length());
2812         int[] r = fr.apply(SPECIES.length());
2813         boolean[] mask = fm.apply(SPECIES.length());
2814         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2815 
2816         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2817             for (int i = 0; i < a.length; i += SPECIES.length()) {
2818                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2819                 av.lanewise(VectorOperators.ASHR, CONST_SHIFT, vmask).intoArray(r, i);
2820             }
2821         }
2822 
2823         assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ASHR_binary_const);
2824     }
2825 


2826     static int ROR_binary_const(int a) {
2827         return (int)(ROR_scalar(a, CONST_SHIFT));
2828     }
2829 
2830     @Test(dataProvider = "intUnaryOpProvider")
2831     static void RORIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
2832         int[] a = fa.apply(SPECIES.length());
2833         int[] r = fr.apply(SPECIES.length());
2834 
2835         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2836             for (int i = 0; i < a.length; i += SPECIES.length()) {
2837                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2838                 av.lanewise(VectorOperators.ROR, CONST_SHIFT).intoArray(r, i);
2839             }
2840         }
2841 
2842         assertShiftConstEquals(r, a, IntMaxVectorTests::ROR_binary_const);
2843     }
2844 


2845     @Test(dataProvider = "intUnaryOpMaskProvider")
2846     static void RORIntMaxVectorTestsScalarShiftMaskedConst(IntFunction<int[]> fa,
2847                                           IntFunction<boolean[]> fm) {
2848         int[] a = fa.apply(SPECIES.length());
2849         int[] r = fr.apply(SPECIES.length());
2850         boolean[] mask = fm.apply(SPECIES.length());
2851         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2852 
2853         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2854             for (int i = 0; i < a.length; i += SPECIES.length()) {
2855                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2856                 av.lanewise(VectorOperators.ROR, CONST_SHIFT, vmask).intoArray(r, i);
2857             }
2858         }
2859 
2860         assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ROR_binary_const);
2861     }
2862 


2863     static int ROL_binary_const(int a) {
2864         return (int)(ROL_scalar(a, CONST_SHIFT));
2865     }
2866 
2867     @Test(dataProvider = "intUnaryOpProvider")
2868     static void ROLIntMaxVectorTestsScalarShiftConst(IntFunction<int[]> fa) {
2869         int[] a = fa.apply(SPECIES.length());
2870         int[] r = fr.apply(SPECIES.length());
2871 
2872         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2873             for (int i = 0; i < a.length; i += SPECIES.length()) {
2874                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2875                 av.lanewise(VectorOperators.ROL, CONST_SHIFT).intoArray(r, i);
2876             }
2877         }
2878 
2879         assertShiftConstEquals(r, a, IntMaxVectorTests::ROL_binary_const);
2880     }
2881 


2882     @Test(dataProvider = "intUnaryOpMaskProvider")
2883     static void ROLIntMaxVectorTestsScalarShiftMaskedConst(IntFunction<int[]> fa,
2884                                           IntFunction<boolean[]> fm) {
2885         int[] a = fa.apply(SPECIES.length());
2886         int[] r = fr.apply(SPECIES.length());
2887         boolean[] mask = fm.apply(SPECIES.length());
2888         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
2889 
2890         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2891             for (int i = 0; i < a.length; i += SPECIES.length()) {
2892                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2893                 av.lanewise(VectorOperators.ROL, CONST_SHIFT, vmask).intoArray(r, i);
2894             }
2895         }
2896 
2897         assertShiftConstEquals(r, a, mask, IntMaxVectorTests::ROL_binary_const);
2898     }
2899 
2900 
2901     static int MIN(int a, int b) {
2902         return (int)(Math.min(a, b));
2903     }
2904 
2905     @Test(dataProvider = "intBinaryOpProvider")
2906     static void MINIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2907         int[] a = fa.apply(SPECIES.length());
2908         int[] b = fb.apply(SPECIES.length());
2909         int[] r = fr.apply(SPECIES.length());
2910 
2911         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2912             for (int i = 0; i < a.length; i += SPECIES.length()) {
2913                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2914                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2915                 av.lanewise(VectorOperators.MIN, bv).intoArray(r, i);
2916             }
2917         }
2918 
2919         assertArraysEquals(r, a, b, IntMaxVectorTests::MIN);
2920     }
2921 
2922     static int min(int a, int b) {
2923         return (int)(Math.min(a, b));
2924     }
2925 
2926     @Test(dataProvider = "intBinaryOpProvider")
2927     static void minIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2928         int[] a = fa.apply(SPECIES.length());
2929         int[] b = fb.apply(SPECIES.length());
2930         int[] r = fr.apply(SPECIES.length());
2931 
2932         for (int i = 0; i < a.length; i += SPECIES.length()) {
2933             IntVector av = IntVector.fromArray(SPECIES, a, i);
2934             IntVector bv = IntVector.fromArray(SPECIES, b, i);
2935             av.min(bv).intoArray(r, i);
2936         }
2937 
2938         assertArraysEquals(r, a, b, IntMaxVectorTests::min);
2939     }
2940 
2941     static int MAX(int a, int b) {
2942         return (int)(Math.max(a, b));
2943     }
2944 
2945     @Test(dataProvider = "intBinaryOpProvider")
2946     static void MAXIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2947         int[] a = fa.apply(SPECIES.length());
2948         int[] b = fb.apply(SPECIES.length());
2949         int[] r = fr.apply(SPECIES.length());
2950 
2951         for (int ic = 0; ic < INVOC_COUNT; ic++) {
2952             for (int i = 0; i < a.length; i += SPECIES.length()) {
2953                 IntVector av = IntVector.fromArray(SPECIES, a, i);
2954                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
2955                 av.lanewise(VectorOperators.MAX, bv).intoArray(r, i);
2956             }
2957         }
2958 
2959         assertArraysEquals(r, a, b, IntMaxVectorTests::MAX);
2960     }
2961 
2962     static int max(int a, int b) {
2963         return (int)(Math.max(a, b));
2964     }
2965 
2966     @Test(dataProvider = "intBinaryOpProvider")
2967     static void maxIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
2968         int[] a = fa.apply(SPECIES.length());
2969         int[] b = fb.apply(SPECIES.length());
2970         int[] r = fr.apply(SPECIES.length());
2971 
2972         for (int i = 0; i < a.length; i += SPECIES.length()) {
2973             IntVector av = IntVector.fromArray(SPECIES, a, i);
2974             IntVector bv = IntVector.fromArray(SPECIES, b, i);
2975             av.max(bv).intoArray(r, i);
2976         }
2977 
2978         assertArraysEquals(r, a, b, IntMaxVectorTests::max);
2979     }
2980 
2981     @Test(dataProvider = "intBinaryOpProvider")

3035     }
3036 
3037     static int ANDReduce(int[] a, int idx) {
3038         int res = -1;
3039         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3040             res &= a[i];
3041         }
3042 
3043         return res;
3044     }
3045 
3046     static int ANDReduceAll(int[] a) {
3047         int res = -1;
3048         for (int i = 0; i < a.length; i += SPECIES.length()) {
3049             res &= ANDReduce(a, i);
3050         }
3051 
3052         return res;
3053     }
3054 

3055     @Test(dataProvider = "intUnaryOpProvider")
3056     static void ANDReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3057         int[] a = fa.apply(SPECIES.length());
3058         int[] r = fr.apply(SPECIES.length());
3059         int ra = -1;
3060 
3061         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3062             for (int i = 0; i < a.length; i += SPECIES.length()) {
3063                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3064                 r[i] = av.reduceLanes(VectorOperators.AND);
3065             }
3066         }
3067 
3068         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3069             ra = -1;
3070             for (int i = 0; i < a.length; i += SPECIES.length()) {
3071                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3072                 ra &= av.reduceLanes(VectorOperators.AND);
3073             }
3074         }
3075 
3076         assertReductionArraysEquals(r, ra, a,
3077                 IntMaxVectorTests::ANDReduce, IntMaxVectorTests::ANDReduceAll);
3078     }
3079 

3080     static int ANDReduceMasked(int[] a, int idx, boolean[] mask) {
3081         int res = -1;
3082         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3083             if (mask[i % SPECIES.length()])
3084                 res &= a[i];
3085         }
3086 
3087         return res;
3088     }
3089 
3090     static int ANDReduceAllMasked(int[] a, boolean[] mask) {
3091         int res = -1;
3092         for (int i = 0; i < a.length; i += SPECIES.length()) {
3093             res &= ANDReduceMasked(a, i, mask);
3094         }
3095 
3096         return res;
3097     }
3098 

3099     @Test(dataProvider = "intUnaryOpMaskProvider")
3100     static void ANDReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3101         int[] a = fa.apply(SPECIES.length());
3102         int[] r = fr.apply(SPECIES.length());
3103         boolean[] mask = fm.apply(SPECIES.length());
3104         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3105         int ra = -1;
3106 
3107         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3108             for (int i = 0; i < a.length; i += SPECIES.length()) {
3109                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3110                 r[i] = av.reduceLanes(VectorOperators.AND, vmask);
3111             }
3112         }
3113 
3114         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3115             ra = -1;
3116             for (int i = 0; i < a.length; i += SPECIES.length()) {
3117                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3118                 ra &= av.reduceLanes(VectorOperators.AND, vmask);
3119             }
3120         }
3121 
3122         assertReductionArraysEqualsMasked(r, ra, a, mask,
3123                 IntMaxVectorTests::ANDReduceMasked, IntMaxVectorTests::ANDReduceAllMasked);
3124     }
3125 

3126     static int ORReduce(int[] a, int idx) {
3127         int res = 0;
3128         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3129             res |= a[i];
3130         }
3131 
3132         return res;
3133     }
3134 
3135     static int ORReduceAll(int[] a) {
3136         int res = 0;
3137         for (int i = 0; i < a.length; i += SPECIES.length()) {
3138             res |= ORReduce(a, i);
3139         }
3140 
3141         return res;
3142     }
3143 

3144     @Test(dataProvider = "intUnaryOpProvider")
3145     static void ORReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3146         int[] a = fa.apply(SPECIES.length());
3147         int[] r = fr.apply(SPECIES.length());
3148         int ra = 0;
3149 
3150         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3151             for (int i = 0; i < a.length; i += SPECIES.length()) {
3152                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3153                 r[i] = av.reduceLanes(VectorOperators.OR);
3154             }
3155         }
3156 
3157         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3158             ra = 0;
3159             for (int i = 0; i < a.length; i += SPECIES.length()) {
3160                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3161                 ra |= av.reduceLanes(VectorOperators.OR);
3162             }
3163         }
3164 
3165         assertReductionArraysEquals(r, ra, a,
3166                 IntMaxVectorTests::ORReduce, IntMaxVectorTests::ORReduceAll);
3167     }
3168 

3169     static int ORReduceMasked(int[] a, int idx, boolean[] mask) {
3170         int res = 0;
3171         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3172             if (mask[i % SPECIES.length()])
3173                 res |= a[i];
3174         }
3175 
3176         return res;
3177     }
3178 
3179     static int ORReduceAllMasked(int[] a, boolean[] mask) {
3180         int res = 0;
3181         for (int i = 0; i < a.length; i += SPECIES.length()) {
3182             res |= ORReduceMasked(a, i, mask);
3183         }
3184 
3185         return res;
3186     }
3187 

3188     @Test(dataProvider = "intUnaryOpMaskProvider")
3189     static void ORReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3190         int[] a = fa.apply(SPECIES.length());
3191         int[] r = fr.apply(SPECIES.length());
3192         boolean[] mask = fm.apply(SPECIES.length());
3193         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3194         int ra = 0;
3195 
3196         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3197             for (int i = 0; i < a.length; i += SPECIES.length()) {
3198                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3199                 r[i] = av.reduceLanes(VectorOperators.OR, vmask);
3200             }
3201         }
3202 
3203         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3204             ra = 0;
3205             for (int i = 0; i < a.length; i += SPECIES.length()) {
3206                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3207                 ra |= av.reduceLanes(VectorOperators.OR, vmask);
3208             }
3209         }
3210 
3211         assertReductionArraysEqualsMasked(r, ra, a, mask,
3212                 IntMaxVectorTests::ORReduceMasked, IntMaxVectorTests::ORReduceAllMasked);
3213     }
3214 

3215     static int XORReduce(int[] a, int idx) {
3216         int res = 0;
3217         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3218             res ^= a[i];
3219         }
3220 
3221         return res;
3222     }
3223 
3224     static int XORReduceAll(int[] a) {
3225         int res = 0;
3226         for (int i = 0; i < a.length; i += SPECIES.length()) {
3227             res ^= XORReduce(a, i);
3228         }
3229 
3230         return res;
3231     }
3232 

3233     @Test(dataProvider = "intUnaryOpProvider")
3234     static void XORReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3235         int[] a = fa.apply(SPECIES.length());
3236         int[] r = fr.apply(SPECIES.length());
3237         int ra = 0;
3238 
3239         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3240             for (int i = 0; i < a.length; i += SPECIES.length()) {
3241                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3242                 r[i] = av.reduceLanes(VectorOperators.XOR);
3243             }
3244         }
3245 
3246         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3247             ra = 0;
3248             for (int i = 0; i < a.length; i += SPECIES.length()) {
3249                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3250                 ra ^= av.reduceLanes(VectorOperators.XOR);
3251             }
3252         }
3253 
3254         assertReductionArraysEquals(r, ra, a,
3255                 IntMaxVectorTests::XORReduce, IntMaxVectorTests::XORReduceAll);
3256     }
3257 

3258     static int XORReduceMasked(int[] a, int idx, boolean[] mask) {
3259         int res = 0;
3260         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3261             if (mask[i % SPECIES.length()])
3262                 res ^= a[i];
3263         }
3264 
3265         return res;
3266     }
3267 
3268     static int XORReduceAllMasked(int[] a, boolean[] mask) {
3269         int res = 0;
3270         for (int i = 0; i < a.length; i += SPECIES.length()) {
3271             res ^= XORReduceMasked(a, i, mask);
3272         }
3273 
3274         return res;
3275     }
3276 

3277     @Test(dataProvider = "intUnaryOpMaskProvider")
3278     static void XORReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3279         int[] a = fa.apply(SPECIES.length());
3280         int[] r = fr.apply(SPECIES.length());
3281         boolean[] mask = fm.apply(SPECIES.length());
3282         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3283         int ra = 0;
3284 
3285         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3286             for (int i = 0; i < a.length; i += SPECIES.length()) {
3287                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3288                 r[i] = av.reduceLanes(VectorOperators.XOR, vmask);
3289             }
3290         }
3291 
3292         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3293             ra = 0;
3294             for (int i = 0; i < a.length; i += SPECIES.length()) {
3295                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3296                 ra ^= av.reduceLanes(VectorOperators.XOR, vmask);

3301                 IntMaxVectorTests::XORReduceMasked, IntMaxVectorTests::XORReduceAllMasked);
3302     }
3303 
3304     static int ADDReduce(int[] a, int idx) {
3305         int res = 0;
3306         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3307             res += a[i];
3308         }
3309 
3310         return res;
3311     }
3312 
3313     static int ADDReduceAll(int[] a) {
3314         int res = 0;
3315         for (int i = 0; i < a.length; i += SPECIES.length()) {
3316             res += ADDReduce(a, i);
3317         }
3318 
3319         return res;
3320     }
3321 
3322     @Test(dataProvider = "intUnaryOpProvider")
3323     static void ADDReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3324         int[] a = fa.apply(SPECIES.length());
3325         int[] r = fr.apply(SPECIES.length());
3326         int ra = 0;
3327 
3328         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3329             for (int i = 0; i < a.length; i += SPECIES.length()) {
3330                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3331                 r[i] = av.reduceLanes(VectorOperators.ADD);
3332             }
3333         }
3334 
3335         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3336             ra = 0;
3337             for (int i = 0; i < a.length; i += SPECIES.length()) {
3338                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3339                 ra += av.reduceLanes(VectorOperators.ADD);
3340             }
3341         }
3342 
3343         assertReductionArraysEquals(r, ra, a,
3344                 IntMaxVectorTests::ADDReduce, IntMaxVectorTests::ADDReduceAll);
3345     }
3346 
3347     static int ADDReduceMasked(int[] a, int idx, boolean[] mask) {
3348         int res = 0;
3349         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3350             if (mask[i % SPECIES.length()])
3351                 res += a[i];
3352         }
3353 
3354         return res;
3355     }
3356 
3357     static int ADDReduceAllMasked(int[] a, boolean[] mask) {
3358         int res = 0;
3359         for (int i = 0; i < a.length; i += SPECIES.length()) {
3360             res += ADDReduceMasked(a, i, mask);
3361         }
3362 
3363         return res;
3364     }
3365 
3366     @Test(dataProvider = "intUnaryOpMaskProvider")
3367     static void ADDReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3368         int[] a = fa.apply(SPECIES.length());
3369         int[] r = fr.apply(SPECIES.length());
3370         boolean[] mask = fm.apply(SPECIES.length());
3371         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3372         int ra = 0;
3373 
3374         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3375             for (int i = 0; i < a.length; i += SPECIES.length()) {
3376                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3377                 r[i] = av.reduceLanes(VectorOperators.ADD, vmask);
3378             }
3379         }
3380 
3381         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3382             ra = 0;
3383             for (int i = 0; i < a.length; i += SPECIES.length()) {
3384                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3385                 ra += av.reduceLanes(VectorOperators.ADD, vmask);
3386             }
3387         }
3388 
3389         assertReductionArraysEqualsMasked(r, ra, a, mask,
3390                 IntMaxVectorTests::ADDReduceMasked, IntMaxVectorTests::ADDReduceAllMasked);
3391     }
3392 
3393     static int MULReduce(int[] a, int idx) {
3394         int res = 1;
3395         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3396             res *= a[i];
3397         }
3398 
3399         return res;
3400     }
3401 
3402     static int MULReduceAll(int[] a) {
3403         int res = 1;
3404         for (int i = 0; i < a.length; i += SPECIES.length()) {
3405             res *= MULReduce(a, i);
3406         }
3407 
3408         return res;
3409     }
3410 
3411     @Test(dataProvider = "intUnaryOpProvider")
3412     static void MULReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3413         int[] a = fa.apply(SPECIES.length());
3414         int[] r = fr.apply(SPECIES.length());
3415         int ra = 1;
3416 
3417         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3418             for (int i = 0; i < a.length; i += SPECIES.length()) {
3419                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3420                 r[i] = av.reduceLanes(VectorOperators.MUL);
3421             }
3422         }
3423 
3424         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3425             ra = 1;
3426             for (int i = 0; i < a.length; i += SPECIES.length()) {
3427                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3428                 ra *= av.reduceLanes(VectorOperators.MUL);
3429             }
3430         }
3431 
3432         assertReductionArraysEquals(r, ra, a,
3433                 IntMaxVectorTests::MULReduce, IntMaxVectorTests::MULReduceAll);
3434     }
3435 
3436     static int MULReduceMasked(int[] a, int idx, boolean[] mask) {
3437         int res = 1;
3438         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3439             if (mask[i % SPECIES.length()])
3440                 res *= a[i];
3441         }
3442 
3443         return res;
3444     }
3445 
3446     static int MULReduceAllMasked(int[] a, boolean[] mask) {
3447         int res = 1;
3448         for (int i = 0; i < a.length; i += SPECIES.length()) {
3449             res *= MULReduceMasked(a, i, mask);
3450         }
3451 
3452         return res;
3453     }
3454 
3455     @Test(dataProvider = "intUnaryOpMaskProvider")
3456     static void MULReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3457         int[] a = fa.apply(SPECIES.length());
3458         int[] r = fr.apply(SPECIES.length());
3459         boolean[] mask = fm.apply(SPECIES.length());
3460         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3461         int ra = 1;
3462 
3463         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3464             for (int i = 0; i < a.length; i += SPECIES.length()) {
3465                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3466                 r[i] = av.reduceLanes(VectorOperators.MUL, vmask);
3467             }
3468         }
3469 
3470         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3471             ra = 1;
3472             for (int i = 0; i < a.length; i += SPECIES.length()) {
3473                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3474                 ra *= av.reduceLanes(VectorOperators.MUL, vmask);
3475             }
3476         }
3477 
3478         assertReductionArraysEqualsMasked(r, ra, a, mask,
3479                 IntMaxVectorTests::MULReduceMasked, IntMaxVectorTests::MULReduceAllMasked);
3480     }
3481 
3482     static int MINReduce(int[] a, int idx) {
3483         int res = Integer.MAX_VALUE;
3484         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3485             res = (int) Math.min(res, a[i]);
3486         }
3487 
3488         return res;
3489     }
3490 
3491     static int MINReduceAll(int[] a) {
3492         int res = Integer.MAX_VALUE;
3493         for (int i = 0; i < a.length; i += SPECIES.length()) {
3494             res = (int) Math.min(res, MINReduce(a, i));
3495         }
3496 
3497         return res;
3498     }
3499 
3500     @Test(dataProvider = "intUnaryOpProvider")
3501     static void MINReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3502         int[] a = fa.apply(SPECIES.length());
3503         int[] r = fr.apply(SPECIES.length());
3504         int ra = Integer.MAX_VALUE;
3505 
3506         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3507             for (int i = 0; i < a.length; i += SPECIES.length()) {
3508                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3509                 r[i] = av.reduceLanes(VectorOperators.MIN);
3510             }
3511         }
3512 
3513         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3514             ra = Integer.MAX_VALUE;
3515             for (int i = 0; i < a.length; i += SPECIES.length()) {
3516                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3517                 ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN));
3518             }
3519         }
3520 
3521         assertReductionArraysEquals(r, ra, a,
3522                 IntMaxVectorTests::MINReduce, IntMaxVectorTests::MINReduceAll);
3523     }
3524 
3525     static int MINReduceMasked(int[] a, int idx, boolean[] mask) {
3526         int res = Integer.MAX_VALUE;
3527         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3528             if (mask[i % SPECIES.length()])
3529                 res = (int) Math.min(res, a[i]);
3530         }
3531 
3532         return res;
3533     }
3534 
3535     static int MINReduceAllMasked(int[] a, boolean[] mask) {
3536         int res = Integer.MAX_VALUE;
3537         for (int i = 0; i < a.length; i += SPECIES.length()) {
3538             res = (int) Math.min(res, MINReduceMasked(a, i, mask));
3539         }
3540 
3541         return res;
3542     }
3543 
3544     @Test(dataProvider = "intUnaryOpMaskProvider")
3545     static void MINReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3546         int[] a = fa.apply(SPECIES.length());
3547         int[] r = fr.apply(SPECIES.length());
3548         boolean[] mask = fm.apply(SPECIES.length());
3549         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3550         int ra = Integer.MAX_VALUE;
3551 
3552         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3553             for (int i = 0; i < a.length; i += SPECIES.length()) {
3554                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3555                 r[i] = av.reduceLanes(VectorOperators.MIN, vmask);
3556             }
3557         }
3558 
3559         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3560             ra = Integer.MAX_VALUE;
3561             for (int i = 0; i < a.length; i += SPECIES.length()) {
3562                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3563                 ra = (int) Math.min(ra, av.reduceLanes(VectorOperators.MIN, vmask));
3564             }
3565         }
3566 
3567         assertReductionArraysEqualsMasked(r, ra, a, mask,
3568                 IntMaxVectorTests::MINReduceMasked, IntMaxVectorTests::MINReduceAllMasked);
3569     }
3570 
3571     static int MAXReduce(int[] a, int idx) {
3572         int res = Integer.MIN_VALUE;
3573         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3574             res = (int) Math.max(res, a[i]);
3575         }
3576 
3577         return res;
3578     }
3579 
3580     static int MAXReduceAll(int[] a) {
3581         int res = Integer.MIN_VALUE;
3582         for (int i = 0; i < a.length; i += SPECIES.length()) {
3583             res = (int) Math.max(res, MAXReduce(a, i));
3584         }
3585 
3586         return res;
3587     }
3588 
3589     @Test(dataProvider = "intUnaryOpProvider")
3590     static void MAXReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3591         int[] a = fa.apply(SPECIES.length());
3592         int[] r = fr.apply(SPECIES.length());
3593         int ra = Integer.MIN_VALUE;
3594 
3595         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3596             for (int i = 0; i < a.length; i += SPECIES.length()) {
3597                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3598                 r[i] = av.reduceLanes(VectorOperators.MAX);
3599             }
3600         }
3601 
3602         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3603             ra = Integer.MIN_VALUE;
3604             for (int i = 0; i < a.length; i += SPECIES.length()) {
3605                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3606                 ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX));
3607             }
3608         }
3609 
3610         assertReductionArraysEquals(r, ra, a,
3611                 IntMaxVectorTests::MAXReduce, IntMaxVectorTests::MAXReduceAll);
3612     }
3613 
3614     static int MAXReduceMasked(int[] a, int idx, boolean[] mask) {
3615         int res = Integer.MIN_VALUE;
3616         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3617             if (mask[i % SPECIES.length()])
3618                 res = (int) Math.max(res, a[i]);
3619         }
3620 
3621         return res;
3622     }
3623 
3624     static int MAXReduceAllMasked(int[] a, boolean[] mask) {
3625         int res = Integer.MIN_VALUE;
3626         for (int i = 0; i < a.length; i += SPECIES.length()) {
3627             res = (int) Math.max(res, MAXReduceMasked(a, i, mask));
3628         }
3629 
3630         return res;
3631     }
3632 
3633     @Test(dataProvider = "intUnaryOpMaskProvider")
3634     static void MAXReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3635         int[] a = fa.apply(SPECIES.length());
3636         int[] r = fr.apply(SPECIES.length());
3637         boolean[] mask = fm.apply(SPECIES.length());
3638         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3639         int ra = Integer.MIN_VALUE;
3640 
3641         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3642             for (int i = 0; i < a.length; i += SPECIES.length()) {
3643                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3644                 r[i] = av.reduceLanes(VectorOperators.MAX, vmask);
3645             }
3646         }
3647 
3648         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3649             ra = Integer.MIN_VALUE;
3650             for (int i = 0; i < a.length; i += SPECIES.length()) {
3651                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3652                 ra = (int) Math.max(ra, av.reduceLanes(VectorOperators.MAX, vmask));
3653             }
3654         }
3655 
3656         assertReductionArraysEqualsMasked(r, ra, a, mask,
3657                 IntMaxVectorTests::MAXReduceMasked, IntMaxVectorTests::MAXReduceAllMasked);
3658     }
3659 
3660     static int FIRST_NONZEROReduce(int[] a, int idx) {
3661         int res = (int) 0;
3662         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3663             res = firstNonZero(res, a[i]);
3664         }
3665 
3666         return res;
3667     }
3668 
3669     static int FIRST_NONZEROReduceAll(int[] a) {
3670         int res = (int) 0;
3671         for (int i = 0; i < a.length; i += SPECIES.length()) {
3672             res = firstNonZero(res, FIRST_NONZEROReduce(a, i));
3673         }
3674 
3675         return res;
3676     }
3677 
3678     @Test(dataProvider = "intUnaryOpProvider")
3679     static void FIRST_NONZEROReduceIntMaxVectorTests(IntFunction<int[]> fa) {
3680         int[] a = fa.apply(SPECIES.length());
3681         int[] r = fr.apply(SPECIES.length());
3682         int ra = (int) 0;
3683 
3684         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3685             for (int i = 0; i < a.length; i += SPECIES.length()) {
3686                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3687                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO);
3688             }
3689         }
3690 
3691         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3692             ra = (int) 0;
3693             for (int i = 0; i < a.length; i += SPECIES.length()) {
3694                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3695                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO));
3696             }
3697         }
3698 
3699         assertReductionArraysEquals(r, ra, a,
3700                 IntMaxVectorTests::FIRST_NONZEROReduce, IntMaxVectorTests::FIRST_NONZEROReduceAll);
3701     }
3702 
3703     static int FIRST_NONZEROReduceMasked(int[] a, int idx, boolean[] mask) {
3704         int res = (int) 0;
3705         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3706             if (mask[i % SPECIES.length()])
3707                 res = firstNonZero(res, a[i]);
3708         }
3709 
3710         return res;
3711     }
3712 
3713     static int FIRST_NONZEROReduceAllMasked(int[] a, boolean[] mask) {
3714         int res = (int) 0;
3715         for (int i = 0; i < a.length; i += SPECIES.length()) {
3716             res = firstNonZero(res, FIRST_NONZEROReduceMasked(a, i, mask));
3717         }
3718 
3719         return res;
3720     }
3721 
3722     @Test(dataProvider = "intUnaryOpMaskProvider")
3723     static void FIRST_NONZEROReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
3724         int[] a = fa.apply(SPECIES.length());
3725         int[] r = fr.apply(SPECIES.length());
3726         boolean[] mask = fm.apply(SPECIES.length());
3727         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3728         int ra = (int) 0;
3729 
3730         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3731             for (int i = 0; i < a.length; i += SPECIES.length()) {
3732                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3733                 r[i] = av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask);
3734             }
3735         }
3736 
3737         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3738             ra = (int) 0;
3739             for (int i = 0; i < a.length; i += SPECIES.length()) {
3740                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3741                 ra = firstNonZero(ra, av.reduceLanes(VectorOperators.FIRST_NONZERO, vmask));
3742             }
3743         }
3744 
3745         assertReductionArraysEqualsMasked(r, ra, a, mask,
3746                 IntMaxVectorTests::FIRST_NONZEROReduceMasked, IntMaxVectorTests::FIRST_NONZEROReduceAllMasked);
3747     }
3748 
3749     static boolean anyTrue(boolean[] a, int idx) {
3750         boolean res = false;
3751         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3752             res |= a[i];
3753         }
3754 
3755         return res;
3756     }
3757 

3758     @Test(dataProvider = "boolUnaryOpProvider")
3759     static void anyTrueIntMaxVectorTests(IntFunction<boolean[]> fm) {
3760         boolean[] mask = fm.apply(SPECIES.length());
3761         boolean[] r = fmr.apply(SPECIES.length());
3762 
3763         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3764             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3765                 VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, i);
3766                 r[i] = vmask.anyTrue();
3767             }
3768         }
3769 
3770         assertReductionBoolArraysEquals(r, mask, IntMaxVectorTests::anyTrue);
3771     }
3772 

3773     static boolean allTrue(boolean[] a, int idx) {
3774         boolean res = true;
3775         for (int i = idx; i < (idx + SPECIES.length()); i++) {
3776             res &= a[i];
3777         }
3778 
3779         return res;
3780     }
3781 

3782     @Test(dataProvider = "boolUnaryOpProvider")
3783     static void allTrueIntMaxVectorTests(IntFunction<boolean[]> fm) {
3784         boolean[] mask = fm.apply(SPECIES.length());
3785         boolean[] r = fmr.apply(SPECIES.length());
3786 
3787         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3788             for (int i = 0; i < mask.length; i += SPECIES.length()) {
3789                 VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, i);
3790                 r[i] = vmask.allTrue();
3791             }
3792         }
3793 
3794         assertReductionBoolArraysEquals(r, mask, IntMaxVectorTests::allTrue);
3795     }
3796 

3797     @Test(dataProvider = "intUnaryOpProvider")
3798     static void withIntMaxVectorTests(IntFunction<int []> fa) {
3799         int[] a = fa.apply(SPECIES.length());
3800         int[] r = fr.apply(SPECIES.length());
3801 
3802         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3803             for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3804                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3805                 av.withLane((j++ & (SPECIES.length()-1)), (int)(65535+i)).intoArray(r, i);
3806             }
3807         }
3808 
3809 
3810         for (int i = 0, j = 0; i < a.length; i += SPECIES.length()) {
3811             assertInsertArraysEquals(r, a, (int)(65535+i), (j++ & (SPECIES.length()-1)), i , i + SPECIES.length());
3812         }
3813     }
3814 
3815     static boolean testIS_DEFAULT(int a) {
3816         return bits(a)==0;
3817     }
3818 
3819     @Test(dataProvider = "intTestOpProvider")
3820     static void IS_DEFAULTIntMaxVectorTests(IntFunction<int[]> fa) {
3821         int[] a = fa.apply(SPECIES.length());
3822 
3823         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3824             for (int i = 0; i < a.length; i += SPECIES.length()) {
3825                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3826                 VectorMask<Integer> mv = av.test(VectorOperators.IS_DEFAULT);
3827 
3828                 // Check results as part of computation.
3829                 for (int j = 0; j < SPECIES.length(); j++) {
3830                     Assert.assertEquals(mv.laneIsSet(j), testIS_DEFAULT(a[i + j]));
3831                 }
3832             }
3833         }
3834     }
3835 
3836     @Test(dataProvider = "intTestOpMaskProvider")
3837     static void IS_DEFAULTMaskedIntMaxVectorTests(IntFunction<int[]> fa,
3838                                           IntFunction<boolean[]> fm) {
3839         int[] a = fa.apply(SPECIES.length());
3840         boolean[] mask = fm.apply(SPECIES.length());
3841         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3842 
3843         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3844             for (int i = 0; i < a.length; i += SPECIES.length()) {
3845                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3846                 VectorMask<Integer> mv = av.test(VectorOperators.IS_DEFAULT, vmask);
3847 
3848                 // Check results as part of computation.
3849                 for (int j = 0; j < SPECIES.length(); j++) {
3850                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_DEFAULT(a[i + j]));
3851                 }
3852             }
3853         }
3854     }
3855 
3856     static boolean testIS_NEGATIVE(int a) {
3857         return bits(a)<0;
3858     }
3859 
3860     @Test(dataProvider = "intTestOpProvider")
3861     static void IS_NEGATIVEIntMaxVectorTests(IntFunction<int[]> fa) {
3862         int[] a = fa.apply(SPECIES.length());
3863 
3864         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3865             for (int i = 0; i < a.length; i += SPECIES.length()) {
3866                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3867                 VectorMask<Integer> mv = av.test(VectorOperators.IS_NEGATIVE);
3868 
3869                 // Check results as part of computation.
3870                 for (int j = 0; j < SPECIES.length(); j++) {
3871                     Assert.assertEquals(mv.laneIsSet(j), testIS_NEGATIVE(a[i + j]));
3872                 }
3873             }
3874         }
3875     }

3877     @Test(dataProvider = "intTestOpMaskProvider")
3878     static void IS_NEGATIVEMaskedIntMaxVectorTests(IntFunction<int[]> fa,
3879                                           IntFunction<boolean[]> fm) {
3880         int[] a = fa.apply(SPECIES.length());
3881         boolean[] mask = fm.apply(SPECIES.length());
3882         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3883 
3884         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3885             for (int i = 0; i < a.length; i += SPECIES.length()) {
3886                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3887                 VectorMask<Integer> mv = av.test(VectorOperators.IS_NEGATIVE, vmask);
3888 
3889                 // Check results as part of computation.
3890                 for (int j = 0; j < SPECIES.length(); j++) {
3891                     Assert.assertEquals(mv.laneIsSet(j),  vmask.laneIsSet(j) && testIS_NEGATIVE(a[i + j]));
3892                 }
3893             }
3894         }
3895     }
3896 



3897     @Test(dataProvider = "intCompareOpProvider")
3898     static void LTIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3899         int[] a = fa.apply(SPECIES.length());
3900         int[] b = fb.apply(SPECIES.length());
3901 
3902         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3903             for (int i = 0; i < a.length; i += SPECIES.length()) {
3904                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3905                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3906                 VectorMask<Integer> mv = av.compare(VectorOperators.LT, bv);
3907 
3908                 // Check results as part of computation.
3909                 for (int j = 0; j < SPECIES.length(); j++) {
3910                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3911                 }
3912             }
3913         }
3914     }
3915 

3916     @Test(dataProvider = "intCompareOpProvider")
3917     static void ltIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3918         int[] a = fa.apply(SPECIES.length());
3919         int[] b = fb.apply(SPECIES.length());
3920 
3921         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3922             for (int i = 0; i < a.length; i += SPECIES.length()) {
3923                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3924                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3925                 VectorMask<Integer> mv = av.lt(bv);
3926 
3927                 // Check results as part of computation.
3928                 for (int j = 0; j < SPECIES.length(); j++) {
3929                     Assert.assertEquals(mv.laneIsSet(j), lt(a[i + j], b[i + j]));
3930                 }
3931             }
3932         }
3933     }
3934 
3935     @Test(dataProvider = "intCompareOpMaskProvider")

3938         int[] a = fa.apply(SPECIES.length());
3939         int[] b = fb.apply(SPECIES.length());
3940         boolean[] mask = fm.apply(SPECIES.length());
3941 
3942         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
3943 
3944         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3945             for (int i = 0; i < a.length; i += SPECIES.length()) {
3946                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3947                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3948                 VectorMask<Integer> mv = av.compare(VectorOperators.LT, bv, vmask);
3949 
3950                 // Check results as part of computation.
3951                 for (int j = 0; j < SPECIES.length(); j++) {
3952                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && lt(a[i + j], b[i + j]));
3953                 }
3954             }
3955         }
3956     }
3957 

3958     @Test(dataProvider = "intCompareOpProvider")
3959     static void GTIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
3960         int[] a = fa.apply(SPECIES.length());
3961         int[] b = fb.apply(SPECIES.length());
3962 
3963         for (int ic = 0; ic < INVOC_COUNT; ic++) {
3964             for (int i = 0; i < a.length; i += SPECIES.length()) {
3965                 IntVector av = IntVector.fromArray(SPECIES, a, i);
3966                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
3967                 VectorMask<Integer> mv = av.compare(VectorOperators.GT, bv);
3968 
3969                 // Check results as part of computation.
3970                 for (int j = 0; j < SPECIES.length(); j++) {
3971                     Assert.assertEquals(mv.laneIsSet(j), gt(a[i + j], b[i + j]));
3972                 }
3973             }
3974         }
3975     }
3976 
3977     @Test(dataProvider = "intCompareOpMaskProvider")

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

4000     @Test(dataProvider = "intCompareOpProvider")
4001     static void EQIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4002         int[] a = fa.apply(SPECIES.length());
4003         int[] 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                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4008                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4009                 VectorMask<Integer> mv = av.compare(VectorOperators.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 = "intCompareOpProvider")
4020     static void eqIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4021         int[] a = fa.apply(SPECIES.length());
4022         int[] b = fb.apply(SPECIES.length());
4023 
4024         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4025             for (int i = 0; i < a.length; i += SPECIES.length()) {
4026                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4027                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4028                 VectorMask<Integer> mv = av.eq(bv);
4029 
4030                 // Check results as part of computation.
4031                 for (int j = 0; j < SPECIES.length(); j++) {
4032                     Assert.assertEquals(mv.laneIsSet(j), eq(a[i + j], b[i + j]));
4033                 }
4034             }
4035         }
4036     }
4037 
4038     @Test(dataProvider = "intCompareOpMaskProvider")

4041         int[] a = fa.apply(SPECIES.length());
4042         int[] b = fb.apply(SPECIES.length());
4043         boolean[] mask = fm.apply(SPECIES.length());
4044 
4045         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4046 
4047         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4048             for (int i = 0; i < a.length; i += SPECIES.length()) {
4049                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4050                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4051                 VectorMask<Integer> mv = av.compare(VectorOperators.EQ, bv, vmask);
4052 
4053                 // Check results as part of computation.
4054                 for (int j = 0; j < SPECIES.length(); j++) {
4055                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && eq(a[i + j], b[i + j]));
4056                 }
4057             }
4058         }
4059     }
4060 

4061     @Test(dataProvider = "intCompareOpProvider")
4062     static void NEIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4063         int[] a = fa.apply(SPECIES.length());
4064         int[] b = fb.apply(SPECIES.length());
4065 
4066         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4067             for (int i = 0; i < a.length; i += SPECIES.length()) {
4068                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4069                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4070                 VectorMask<Integer> mv = av.compare(VectorOperators.NE, bv);
4071 
4072                 // Check results as part of computation.
4073                 for (int j = 0; j < SPECIES.length(); j++) {
4074                     Assert.assertEquals(mv.laneIsSet(j), neq(a[i + j], b[i + j]));
4075                 }
4076             }
4077         }
4078     }
4079 
4080     @Test(dataProvider = "intCompareOpMaskProvider")

4083         int[] a = fa.apply(SPECIES.length());
4084         int[] b = fb.apply(SPECIES.length());
4085         boolean[] mask = fm.apply(SPECIES.length());
4086 
4087         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4088 
4089         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4090             for (int i = 0; i < a.length; i += SPECIES.length()) {
4091                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4092                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4093                 VectorMask<Integer> mv = av.compare(VectorOperators.NE, bv, vmask);
4094 
4095                 // Check results as part of computation.
4096                 for (int j = 0; j < SPECIES.length(); j++) {
4097                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && neq(a[i + j], b[i + j]));
4098                 }
4099             }
4100         }
4101     }
4102 

4103     @Test(dataProvider = "intCompareOpProvider")
4104     static void LEIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4105         int[] a = fa.apply(SPECIES.length());
4106         int[] b = fb.apply(SPECIES.length());
4107 
4108         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4109             for (int i = 0; i < a.length; i += SPECIES.length()) {
4110                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4111                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4112                 VectorMask<Integer> mv = av.compare(VectorOperators.LE, bv);
4113 
4114                 // Check results as part of computation.
4115                 for (int j = 0; j < SPECIES.length(); j++) {
4116                     Assert.assertEquals(mv.laneIsSet(j), le(a[i + j], b[i + j]));
4117                 }
4118             }
4119         }
4120     }
4121 
4122     @Test(dataProvider = "intCompareOpMaskProvider")

4125         int[] a = fa.apply(SPECIES.length());
4126         int[] b = fb.apply(SPECIES.length());
4127         boolean[] mask = fm.apply(SPECIES.length());
4128 
4129         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4130 
4131         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4132             for (int i = 0; i < a.length; i += SPECIES.length()) {
4133                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4134                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4135                 VectorMask<Integer> mv = av.compare(VectorOperators.LE, bv, vmask);
4136 
4137                 // Check results as part of computation.
4138                 for (int j = 0; j < SPECIES.length(); j++) {
4139                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && le(a[i + j], b[i + j]));
4140                 }
4141             }
4142         }
4143     }
4144 

4145     @Test(dataProvider = "intCompareOpProvider")
4146     static void GEIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4147         int[] a = fa.apply(SPECIES.length());
4148         int[] b = fb.apply(SPECIES.length());
4149 
4150         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4151             for (int i = 0; i < a.length; i += SPECIES.length()) {
4152                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4153                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4154                 VectorMask<Integer> mv = av.compare(VectorOperators.GE, bv);
4155 
4156                 // Check results as part of computation.
4157                 for (int j = 0; j < SPECIES.length(); j++) {
4158                     Assert.assertEquals(mv.laneIsSet(j), ge(a[i + j], b[i + j]));
4159                 }
4160             }
4161         }
4162     }
4163 
4164     @Test(dataProvider = "intCompareOpMaskProvider")

4167         int[] a = fa.apply(SPECIES.length());
4168         int[] b = fb.apply(SPECIES.length());
4169         boolean[] mask = fm.apply(SPECIES.length());
4170 
4171         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4172 
4173         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4174             for (int i = 0; i < a.length; i += SPECIES.length()) {
4175                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4176                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4177                 VectorMask<Integer> mv = av.compare(VectorOperators.GE, bv, vmask);
4178 
4179                 // Check results as part of computation.
4180                 for (int j = 0; j < SPECIES.length(); j++) {
4181                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ge(a[i + j], b[i + j]));
4182                 }
4183             }
4184         }
4185     }
4186 


4187     @Test(dataProvider = "intCompareOpProvider")
4188     static void UNSIGNED_LTIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4189         int[] a = fa.apply(SPECIES.length());
4190         int[] b = fb.apply(SPECIES.length());
4191 
4192         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4193             for (int i = 0; i < a.length; i += SPECIES.length()) {
4194                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4195                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4196                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv);
4197 
4198                 // Check results as part of computation.
4199                 for (int j = 0; j < SPECIES.length(); j++) {
4200                     Assert.assertEquals(mv.laneIsSet(j), ult(a[i + j], b[i + j]));
4201                 }
4202             }
4203         }
4204     }
4205 


4206     @Test(dataProvider = "intCompareOpMaskProvider")
4207     static void UNSIGNED_LTIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4208                                                 IntFunction<boolean[]> fm) {
4209         int[] a = fa.apply(SPECIES.length());
4210         int[] b = fb.apply(SPECIES.length());
4211         boolean[] mask = fm.apply(SPECIES.length());
4212 
4213         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4214 
4215         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4216             for (int i = 0; i < a.length; i += SPECIES.length()) {
4217                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4218                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4219                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask);
4220 
4221                 // Check results as part of computation.
4222                 for (int j = 0; j < SPECIES.length(); j++) {
4223                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ult(a[i + j], b[i + j]));
4224                 }
4225             }
4226         }
4227     }
4228 



4229     @Test(dataProvider = "intCompareOpProvider")
4230     static void UNSIGNED_GTIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4231         int[] a = fa.apply(SPECIES.length());
4232         int[] b = fb.apply(SPECIES.length());
4233 
4234         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4235             for (int i = 0; i < a.length; i += SPECIES.length()) {
4236                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4237                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4238                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv);
4239 
4240                 // Check results as part of computation.
4241                 for (int j = 0; j < SPECIES.length(); j++) {
4242                     Assert.assertEquals(mv.laneIsSet(j), ugt(a[i + j], b[i + j]));
4243                 }
4244             }
4245         }
4246     }
4247 


4248     @Test(dataProvider = "intCompareOpMaskProvider")
4249     static void UNSIGNED_GTIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4250                                                 IntFunction<boolean[]> fm) {
4251         int[] a = fa.apply(SPECIES.length());
4252         int[] b = fb.apply(SPECIES.length());
4253         boolean[] mask = fm.apply(SPECIES.length());
4254 
4255         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4256 
4257         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4258             for (int i = 0; i < a.length; i += SPECIES.length()) {
4259                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4260                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4261                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask);
4262 
4263                 // Check results as part of computation.
4264                 for (int j = 0; j < SPECIES.length(); j++) {
4265                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ugt(a[i + j], b[i + j]));
4266                 }
4267             }
4268         }
4269     }
4270 



4271     @Test(dataProvider = "intCompareOpProvider")
4272     static void UNSIGNED_LEIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4273         int[] a = fa.apply(SPECIES.length());
4274         int[] b = fb.apply(SPECIES.length());
4275 
4276         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4277             for (int i = 0; i < a.length; i += SPECIES.length()) {
4278                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4279                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4280                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv);
4281 
4282                 // Check results as part of computation.
4283                 for (int j = 0; j < SPECIES.length(); j++) {
4284                     Assert.assertEquals(mv.laneIsSet(j), ule(a[i + j], b[i + j]));
4285                 }
4286             }
4287         }
4288     }
4289 


4290     @Test(dataProvider = "intCompareOpMaskProvider")
4291     static void UNSIGNED_LEIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4292                                                 IntFunction<boolean[]> fm) {
4293         int[] a = fa.apply(SPECIES.length());
4294         int[] b = fb.apply(SPECIES.length());
4295         boolean[] mask = fm.apply(SPECIES.length());
4296 
4297         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4298 
4299         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4300             for (int i = 0; i < a.length; i += SPECIES.length()) {
4301                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4302                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4303                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask);
4304 
4305                 // Check results as part of computation.
4306                 for (int j = 0; j < SPECIES.length(); j++) {
4307                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && ule(a[i + j], b[i + j]));
4308                 }
4309             }
4310         }
4311     }
4312 



4313     @Test(dataProvider = "intCompareOpProvider")
4314     static void UNSIGNED_GEIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4315         int[] a = fa.apply(SPECIES.length());
4316         int[] b = fb.apply(SPECIES.length());
4317 
4318         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4319             for (int i = 0; i < a.length; i += SPECIES.length()) {
4320                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4321                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4322                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv);
4323 
4324                 // Check results as part of computation.
4325                 for (int j = 0; j < SPECIES.length(); j++) {
4326                     Assert.assertEquals(mv.laneIsSet(j), uge(a[i + j], b[i + j]));
4327                 }
4328             }
4329         }
4330     }
4331 


4332     @Test(dataProvider = "intCompareOpMaskProvider")
4333     static void UNSIGNED_GEIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4334                                                 IntFunction<boolean[]> fm) {
4335         int[] a = fa.apply(SPECIES.length());
4336         int[] b = fb.apply(SPECIES.length());
4337         boolean[] mask = fm.apply(SPECIES.length());
4338 
4339         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4340 
4341         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4342             for (int i = 0; i < a.length; i += SPECIES.length()) {
4343                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4344                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4345                 VectorMask<Integer> mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask);
4346 
4347                 // Check results as part of computation.
4348                 for (int j = 0; j < SPECIES.length(); j++) {
4349                     Assert.assertEquals(mv.laneIsSet(j), mask[j] && uge(a[i + j], b[i + j]));
4350                 }
4351             }
4352         }
4353     }
4354 


4355     @Test(dataProvider = "intCompareOpProvider")
4356     static void LTIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4357         int[] a = fa.apply(SPECIES.length());
4358         int[] b = fb.apply(SPECIES.length());
4359 
4360         for (int i = 0; i < a.length; i += SPECIES.length()) {
4361             IntVector av = IntVector.fromArray(SPECIES, a, i);
4362             VectorMask<Integer> mv = av.compare(VectorOperators.LT, b[i]);
4363 
4364             // Check results as part of computation.
4365             for (int j = 0; j < SPECIES.length(); j++) {
4366                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
4367             }
4368         }
4369     }
4370 

4371     @Test(dataProvider = "intCompareOpMaskProvider")
4372     static void LTIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa,
4373                                 IntFunction<int[]> fb, IntFunction<boolean[]> fm) {
4374         int[] a = fa.apply(SPECIES.length());
4375         int[] b = fb.apply(SPECIES.length());
4376         boolean[] mask = fm.apply(SPECIES.length());
4377 
4378         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4379 
4380         for (int i = 0; i < a.length; i += SPECIES.length()) {
4381             IntVector av = IntVector.fromArray(SPECIES, a, i);
4382             VectorMask<Integer> mv = av.compare(VectorOperators.LT, b[i], vmask);
4383 
4384             // Check results as part of computation.
4385             for (int j = 0; j < SPECIES.length(); j++) {
4386                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < b[i]));
4387             }
4388         }
4389     }
4390 
4391     @Test(dataProvider = "intCompareOpProvider")
4392     static void LTIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4393         int[] a = fa.apply(SPECIES.length());
4394         int[] b = fb.apply(SPECIES.length());
4395 
4396         for (int i = 0; i < a.length; i += SPECIES.length()) {
4397             IntVector av = IntVector.fromArray(SPECIES, a, i);
4398             VectorMask<Integer> mv = av.compare(VectorOperators.LT, (long)b[i]);
4399 
4400             // Check results as part of computation.
4401             for (int j = 0; j < SPECIES.length(); j++) {
4402                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < (int)((long)b[i]));
4403             }
4404         }
4405     }
4406 

4407     @Test(dataProvider = "intCompareOpMaskProvider")
4408     static void LTIntMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<int[]> fa,
4409                                 IntFunction<int[]> fb, IntFunction<boolean[]> fm) {
4410         int[] a = fa.apply(SPECIES.length());
4411         int[] b = fb.apply(SPECIES.length());
4412         boolean[] mask = fm.apply(SPECIES.length());
4413 
4414         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4415 
4416         for (int i = 0; i < a.length; i += SPECIES.length()) {
4417             IntVector av = IntVector.fromArray(SPECIES, a, i);
4418             VectorMask<Integer> mv = av.compare(VectorOperators.LT, (long)b[i], vmask);
4419 
4420             // Check results as part of computation.
4421             for (int j = 0; j < SPECIES.length(); j++) {
4422                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] < (int)((long)b[i])));
4423             }
4424         }
4425     }
4426 
4427     @Test(dataProvider = "intCompareOpProvider")
4428     static void EQIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4429         int[] a = fa.apply(SPECIES.length());
4430         int[] b = fb.apply(SPECIES.length());
4431 
4432         for (int i = 0; i < a.length; i += SPECIES.length()) {
4433             IntVector av = IntVector.fromArray(SPECIES, a, i);
4434             VectorMask<Integer> mv = av.compare(VectorOperators.EQ, b[i]);
4435 
4436             // Check results as part of computation.
4437             for (int j = 0; j < SPECIES.length(); j++) {
4438                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == b[i]);
4439             }
4440         }
4441     }
4442 

4443     @Test(dataProvider = "intCompareOpMaskProvider")
4444     static void EQIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa,
4445                                 IntFunction<int[]> fb, IntFunction<boolean[]> fm) {
4446         int[] a = fa.apply(SPECIES.length());
4447         int[] b = fb.apply(SPECIES.length());
4448         boolean[] mask = fm.apply(SPECIES.length());
4449 
4450         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4451 
4452         for (int i = 0; i < a.length; i += SPECIES.length()) {
4453             IntVector av = IntVector.fromArray(SPECIES, a, i);
4454             VectorMask<Integer> mv = av.compare(VectorOperators.EQ, b[i], vmask);
4455 
4456             // Check results as part of computation.
4457             for (int j = 0; j < SPECIES.length(); j++) {
4458                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == b[i]));
4459             }
4460         }
4461     }
4462 
4463     @Test(dataProvider = "intCompareOpProvider")
4464     static void EQIntMaxVectorTestsBroadcastLongSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4465         int[] a = fa.apply(SPECIES.length());
4466         int[] b = fb.apply(SPECIES.length());
4467 
4468         for (int i = 0; i < a.length; i += SPECIES.length()) {
4469             IntVector av = IntVector.fromArray(SPECIES, a, i);
4470             VectorMask<Integer> mv = av.compare(VectorOperators.EQ, (long)b[i]);
4471 
4472             // Check results as part of computation.
4473             for (int j = 0; j < SPECIES.length(); j++) {
4474                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] == (int)((long)b[i]));
4475             }
4476         }
4477     }
4478 

4479     @Test(dataProvider = "intCompareOpMaskProvider")
4480     static void EQIntMaxVectorTestsBroadcastLongMaskedSmokeTest(IntFunction<int[]> fa,
4481                                 IntFunction<int[]> fb, IntFunction<boolean[]> fm) {
4482         int[] a = fa.apply(SPECIES.length());
4483         int[] b = fb.apply(SPECIES.length());
4484         boolean[] mask = fm.apply(SPECIES.length());
4485 
4486         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4487 
4488         for (int i = 0; i < a.length; i += SPECIES.length()) {
4489             IntVector av = IntVector.fromArray(SPECIES, a, i);
4490             VectorMask<Integer> mv = av.compare(VectorOperators.EQ, (long)b[i], vmask);
4491 
4492             // Check results as part of computation.
4493             for (int j = 0; j < SPECIES.length(); j++) {
4494                 Assert.assertEquals(mv.laneIsSet(j), mask[j] && (a[i + j] == (int)((long)b[i])));
4495             }
4496         }
4497     }
4498 

4537         assertRearrangeArraysEquals(r, a, order, SPECIES.length());
4538     }
4539 
4540     @Test(dataProvider = "intUnaryOpShuffleMaskProvider")
4541     static void RearrangeIntMaxVectorTestsMaskedSmokeTest(IntFunction<int[]> fa,
4542                                                           BiFunction<Integer,Integer,int[]> fs,
4543                                                           IntFunction<boolean[]> fm) {
4544         int[] a = fa.apply(SPECIES.length());
4545         int[] order = fs.apply(a.length, SPECIES.length());
4546         int[] r = fr.apply(SPECIES.length());
4547         boolean[] mask = fm.apply(SPECIES.length());
4548         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4549 
4550         for (int i = 0; i < a.length; i += SPECIES.length()) {
4551             IntVector av = IntVector.fromArray(SPECIES, a, i);
4552             av.rearrange(VectorShuffle.fromArray(SPECIES, order, i), vmask).intoArray(r, i);
4553         }
4554 
4555         assertRearrangeArraysEquals(r, a, order, mask, SPECIES.length());
4556     }
4557 
4558     @Test(dataProvider = "intUnaryOpMaskProvider")
4559     static void compressIntMaxVectorTests(IntFunction<int[]> fa,
4560                                                 IntFunction<boolean[]> fm) {
4561         int[] a = fa.apply(SPECIES.length());
4562         int[] r = fr.apply(SPECIES.length());
4563         boolean[] mask = fm.apply(SPECIES.length());
4564         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4565 
4566         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4567             for (int i = 0; i < a.length; i += SPECIES.length()) {
4568                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4569                 av.compress(vmask).intoArray(r, i);
4570             }
4571         }
4572 
4573         assertcompressArraysEquals(r, a, mask, SPECIES.length());
4574     }
4575 
4576     @Test(dataProvider = "intUnaryOpMaskProvider")
4577     static void expandIntMaxVectorTests(IntFunction<int[]> fa,
4578                                                 IntFunction<boolean[]> fm) {
4579         int[] a = fa.apply(SPECIES.length());
4580         int[] r = fr.apply(SPECIES.length());
4581         boolean[] mask = fm.apply(SPECIES.length());
4582         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4583 
4584         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4585             for (int i = 0; i < a.length; i += SPECIES.length()) {
4586                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4587                 av.expand(vmask).intoArray(r, i);
4588             }
4589         }
4590 
4591         assertexpandArraysEquals(r, a, mask, SPECIES.length());
4592     }
4593 
4594     @Test(dataProvider = "intUnaryOpProvider")
4595     static void getIntMaxVectorTests(IntFunction<int[]> fa) {
4596         int[] a = fa.apply(SPECIES.length());
4597         int[] r = fr.apply(SPECIES.length());
4598 
4599         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4600             for (int i = 0; i < a.length; i += SPECIES.length()) {
4601                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4602                 int num_lanes = SPECIES.length();
4603                 // Manually unroll because full unroll happens after intrinsification.
4604                 // Unroll is needed because get intrinsic requires for index to be a known constant.
4605                 if (num_lanes == 1) {
4606                     r[i]=av.lane(0);
4607                 } else if (num_lanes == 2) {
4608                     r[i]=av.lane(0);
4609                     r[i+1]=av.lane(1);
4610                 } else if (num_lanes == 4) {
4611                     r[i]=av.lane(0);
4612                     r[i+1]=av.lane(1);
4613                     r[i+2]=av.lane(2);

4744             }
4745         }
4746 
4747         assertArraysEquals(r, a, IntMaxVectorTests::get);
4748     }
4749 
4750     @Test(dataProvider = "intUnaryOpProvider")
4751     static void BroadcastIntMaxVectorTests(IntFunction<int[]> fa) {
4752         int[] a = fa.apply(SPECIES.length());
4753         int[] r = new int[a.length];
4754 
4755         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4756             for (int i = 0; i < a.length; i += SPECIES.length()) {
4757                 IntVector.broadcast(SPECIES, a[i]).intoArray(r, i);
4758             }
4759         }
4760 
4761         assertBroadcastArraysEquals(r, a);
4762     }
4763 




4764     @Test(dataProvider = "intUnaryOpProvider")
4765     static void ZeroIntMaxVectorTests(IntFunction<int[]> fa) {
4766         int[] a = fa.apply(SPECIES.length());
4767         int[] r = new int[a.length];
4768 
4769         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4770             for (int i = 0; i < a.length; i += SPECIES.length()) {
4771                 IntVector.zero(SPECIES).intoArray(a, i);
4772             }
4773         }
4774 
4775         Assert.assertEquals(a, r);
4776     }
4777 



4778     static int[] sliceUnary(int[] a, int origin, int idx) {
4779         int[] res = new int[SPECIES.length()];
4780         for (int i = 0; i < SPECIES.length(); i++){
4781             if(i+origin < SPECIES.length())
4782                 res[i] = a[idx+i+origin];
4783             else
4784                 res[i] = (int)0;
4785         }
4786         return res;
4787     }
4788 
4789     @Test(dataProvider = "intUnaryOpProvider")
4790     static void sliceUnaryIntMaxVectorTests(IntFunction<int[]> fa) {
4791         int[] a = fa.apply(SPECIES.length());
4792         int[] r = new int[a.length];
4793         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4794         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4795             for (int i = 0; i < a.length; i += SPECIES.length()) {
4796                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4797                 av.slice(origin).intoArray(r, i);
4798             }
4799         }
4800 
4801         assertArraysEquals(r, a, origin, IntMaxVectorTests::sliceUnary);
4802     }
4803 
4804     static int[] sliceBinary(int[] a, int[] b, int origin, int idx) {
4805         int[] res = new int[SPECIES.length()];
4806         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4807             if(i+origin < SPECIES.length())
4808                 res[i] = a[idx+i+origin];
4809             else {
4810                 res[i] = b[idx+j];
4811                 j++;
4812             }
4813         }
4814         return res;
4815     }
4816 
4817     @Test(dataProvider = "intBinaryOpProvider")
4818     static void sliceBinaryIntMaxVectorTestsBinary(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4819         int[] a = fa.apply(SPECIES.length());
4820         int[] b = fb.apply(SPECIES.length());
4821         int[] r = new int[a.length];
4822         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4823         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4824             for (int i = 0; i < a.length; i += SPECIES.length()) {
4825                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4826                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4827                 av.slice(origin, bv).intoArray(r, i);
4828             }
4829         }
4830 
4831         assertArraysEquals(r, a, b, origin, IntMaxVectorTests::sliceBinary);
4832     }
4833 
4834     static int[] slice(int[] a, int[] b, int origin, boolean[] mask, int idx) {
4835         int[] res = new int[SPECIES.length()];
4836         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4837             if(i+origin < SPECIES.length())
4838                 res[i] = mask[i] ? a[idx+i+origin] : (int)0;
4839             else {
4840                 res[i] = mask[i] ? b[idx+j] : (int)0;
4841                 j++;
4842             }
4843         }
4844         return res;
4845     }
4846 
4847     @Test(dataProvider = "intBinaryOpMaskProvider")
4848     static void sliceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4849     IntFunction<boolean[]> fm) {
4850         int[] a = fa.apply(SPECIES.length());
4851         int[] b = fb.apply(SPECIES.length());
4852         boolean[] mask = fm.apply(SPECIES.length());
4853         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4854 
4855         int[] r = new int[a.length];
4856         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4857         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4858             for (int i = 0; i < a.length; i += SPECIES.length()) {
4859                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4860                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4861                 av.slice(origin, bv, vmask).intoArray(r, i);
4862             }
4863         }
4864 
4865         assertArraysEquals(r, a, b, origin, mask, IntMaxVectorTests::slice);
4866     }
4867 
4868     static int[] unsliceUnary(int[] a, int origin, int idx) {
4869         int[] res = new int[SPECIES.length()];
4870         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4871             if(i < origin)
4872                 res[i] = (int)0;
4873             else {
4874                 res[i] = a[idx+j];
4875                 j++;
4876             }
4877         }
4878         return res;
4879     }
4880 
4881     @Test(dataProvider = "intUnaryOpProvider")
4882     static void unsliceUnaryIntMaxVectorTests(IntFunction<int[]> fa) {
4883         int[] a = fa.apply(SPECIES.length());
4884         int[] r = new int[a.length];
4885         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4886         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4887             for (int i = 0; i < a.length; i += SPECIES.length()) {
4888                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4889                 av.unslice(origin).intoArray(r, i);
4890             }
4891         }
4892 
4893         assertArraysEquals(r, a, origin, IntMaxVectorTests::unsliceUnary);
4894     }
4895 
4896     static int[] unsliceBinary(int[] a, int[] b, int origin, int part, int idx) {
4897         int[] res = new int[SPECIES.length()];
4898         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4899             if (part == 0) {
4900                 if (i < origin)
4901                     res[i] = b[idx+i];
4902                 else {
4903                     res[i] = a[idx+j];
4904                     j++;
4905                 }
4906             } else if (part == 1) {
4907                 if (i < origin)
4908                     res[i] = a[idx+SPECIES.length()-origin+i];
4909                 else {
4910                     res[i] = b[idx+origin+j];
4911                     j++;
4912                 }
4913             }
4914         }
4915         return res;
4916     }
4917 
4918     @Test(dataProvider = "intBinaryOpProvider")
4919     static void unsliceBinaryIntMaxVectorTestsBinary(IntFunction<int[]> fa, IntFunction<int[]> fb) {
4920         int[] a = fa.apply(SPECIES.length());
4921         int[] b = fb.apply(SPECIES.length());
4922         int[] r = new int[a.length];
4923         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4924         int part = (new java.util.Random()).nextInt(2);
4925         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4926             for (int i = 0; i < a.length; i += SPECIES.length()) {
4927                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4928                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4929                 av.unslice(origin, bv, part).intoArray(r, i);
4930             }
4931         }
4932 
4933         assertArraysEquals(r, a, b, origin, part, IntMaxVectorTests::unsliceBinary);
4934     }
4935 
4936     static int[] unslice(int[] a, int[] b, int origin, int part, boolean[] mask, int idx) {
4937         int[] res = new int[SPECIES.length()];
4938         for (int i = 0, j = 0; i < SPECIES.length(); i++){
4939             if(i+origin < SPECIES.length())
4940                 res[i] = b[idx+i+origin];
4941             else {
4942                 res[i] = b[idx+j];
4943                 j++;
4944             }
4945         }
4946         for (int i = 0; i < SPECIES.length(); i++){
4947             res[i] = mask[i] ? a[idx+i] : res[i];
4948         }
4949         int[] res1 = new int[SPECIES.length()];
4950         if (part == 0) {
4951             for (int i = 0, j = 0; i < SPECIES.length(); i++){
4952                 if (i < origin)
4953                     res1[i] = b[idx+i];
4954                 else {
4955                    res1[i] = res[j];

4973     static void unsliceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
4974     IntFunction<boolean[]> fm) {
4975         int[] a = fa.apply(SPECIES.length());
4976         int[] b = fb.apply(SPECIES.length());
4977         boolean[] mask = fm.apply(SPECIES.length());
4978         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
4979         int[] r = new int[a.length];
4980         int origin = (new java.util.Random()).nextInt(SPECIES.length());
4981         int part = (new java.util.Random()).nextInt(2);
4982         for (int ic = 0; ic < INVOC_COUNT; ic++) {
4983             for (int i = 0; i < a.length; i += SPECIES.length()) {
4984                 IntVector av = IntVector.fromArray(SPECIES, a, i);
4985                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
4986                 av.unslice(origin, bv, part, vmask).intoArray(r, i);
4987             }
4988         }
4989 
4990         assertArraysEquals(r, a, b, origin, part, mask, IntMaxVectorTests::unslice);
4991     }
4992 






















4993     static int BITWISE_BLEND(int a, int b, int c) {
4994         return (int)((a&~(c))|(b&c));
4995     }
4996 
4997     static int bitwiseBlend(int a, int b, int c) {
4998         return (int)((a&~(c))|(b&c));
4999     }
5000 

5001     @Test(dataProvider = "intTernaryOpProvider")
5002     static void BITWISE_BLENDIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5003         int[] a = fa.apply(SPECIES.length());
5004         int[] b = fb.apply(SPECIES.length());
5005         int[] c = fc.apply(SPECIES.length());
5006         int[] r = fr.apply(SPECIES.length());
5007 
5008         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5009             for (int i = 0; i < a.length; i += SPECIES.length()) {
5010                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5011                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
5012                 IntVector cv = IntVector.fromArray(SPECIES, c, i);
5013                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv).intoArray(r, i);
5014             }
5015         }
5016 
5017         assertArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND);
5018     }
5019 
5020     @Test(dataProvider = "intTernaryOpProvider")
5021     static void bitwiseBlendIntMaxVectorTests(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5022         int[] a = fa.apply(SPECIES.length());
5023         int[] b = fb.apply(SPECIES.length());
5024         int[] c = fc.apply(SPECIES.length());
5025         int[] r = fr.apply(SPECIES.length());
5026 
5027         for (int i = 0; i < a.length; i += SPECIES.length()) {
5028             IntVector av = IntVector.fromArray(SPECIES, a, i);
5029             IntVector bv = IntVector.fromArray(SPECIES, b, i);
5030             IntVector cv = IntVector.fromArray(SPECIES, c, i);
5031             av.bitwiseBlend(bv, cv).intoArray(r, i);
5032         }
5033 
5034         assertArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend);
5035     }
5036 

5037     @Test(dataProvider = "intTernaryOpMaskProvider")
5038     static void BITWISE_BLENDIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<int[]> fb,
5039                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
5040         int[] a = fa.apply(SPECIES.length());
5041         int[] b = fb.apply(SPECIES.length());
5042         int[] c = fc.apply(SPECIES.length());
5043         int[] r = fr.apply(SPECIES.length());
5044         boolean[] mask = fm.apply(SPECIES.length());
5045         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5046 
5047         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5048             for (int i = 0; i < a.length; i += SPECIES.length()) {
5049                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5050                 IntVector bv = IntVector.fromArray(SPECIES, b, i);
5051                 IntVector cv = IntVector.fromArray(SPECIES, c, i);
5052                 av.lanewise(VectorOperators.BITWISE_BLEND, bv, cv, vmask).intoArray(r, i);
5053             }
5054         }
5055 
5056         assertArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND);
5057     }
5058 



5059     @Test(dataProvider = "intTernaryOpProvider")
5060     static void BITWISE_BLENDIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5061         int[] a = fa.apply(SPECIES.length());
5062         int[] b = fb.apply(SPECIES.length());
5063         int[] c = fc.apply(SPECIES.length());
5064         int[] r = fr.apply(SPECIES.length());
5065 
5066         for (int i = 0; i < a.length; i += SPECIES.length()) {
5067             IntVector av = IntVector.fromArray(SPECIES, a, i);
5068             IntVector bv = IntVector.fromArray(SPECIES, b, i);
5069             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i]).intoArray(r, i);
5070         }
5071         assertBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND);
5072     }
5073 
5074     @Test(dataProvider = "intTernaryOpProvider")
5075     static void BITWISE_BLENDIntMaxVectorTestsAltBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5076         int[] a = fa.apply(SPECIES.length());
5077         int[] b = fb.apply(SPECIES.length());
5078         int[] c = fc.apply(SPECIES.length());
5079         int[] r = fr.apply(SPECIES.length());
5080 
5081         for (int i = 0; i < a.length; i += SPECIES.length()) {
5082             IntVector av = IntVector.fromArray(SPECIES, a, i);
5083             IntVector cv = IntVector.fromArray(SPECIES, c, i);
5084             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv).intoArray(r, i);
5085         }
5086         assertAltBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND);
5087     }
5088 
5089     @Test(dataProvider = "intTernaryOpProvider")
5090     static void bitwiseBlendIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5091         int[] a = fa.apply(SPECIES.length());
5092         int[] b = fb.apply(SPECIES.length());
5093         int[] c = fc.apply(SPECIES.length());
5094         int[] r = fr.apply(SPECIES.length());
5095 
5096         for (int i = 0; i < a.length; i += SPECIES.length()) {
5097             IntVector av = IntVector.fromArray(SPECIES, a, i);
5098             IntVector bv = IntVector.fromArray(SPECIES, b, i);
5099             av.bitwiseBlend(bv, c[i]).intoArray(r, i);
5100         }
5101         assertBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend);
5102     }
5103 
5104     @Test(dataProvider = "intTernaryOpProvider")
5105     static void bitwiseBlendIntMaxVectorTestsAltBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5106         int[] a = fa.apply(SPECIES.length());
5107         int[] b = fb.apply(SPECIES.length());
5108         int[] c = fc.apply(SPECIES.length());
5109         int[] r = fr.apply(SPECIES.length());
5110 
5111         for (int i = 0; i < a.length; i += SPECIES.length()) {
5112             IntVector av = IntVector.fromArray(SPECIES, a, i);
5113             IntVector cv = IntVector.fromArray(SPECIES, c, i);
5114             av.bitwiseBlend(b[i], cv).intoArray(r, i);
5115         }
5116         assertAltBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend);
5117     }
5118 

5119     @Test(dataProvider = "intTernaryOpMaskProvider")
5120     static void BITWISE_BLENDIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
5121                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
5122         int[] a = fa.apply(SPECIES.length());
5123         int[] b = fb.apply(SPECIES.length());
5124         int[] c = fc.apply(SPECIES.length());
5125         int[] r = fr.apply(SPECIES.length());
5126         boolean[] mask = fm.apply(SPECIES.length());
5127         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5128 
5129         for (int i = 0; i < a.length; i += SPECIES.length()) {
5130             IntVector av = IntVector.fromArray(SPECIES, a, i);
5131             IntVector bv = IntVector.fromArray(SPECIES, b, i);
5132             av.lanewise(VectorOperators.BITWISE_BLEND, bv, c[i], vmask).intoArray(r, i);
5133         }
5134 
5135         assertBroadcastArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND);
5136     }
5137 
5138     @Test(dataProvider = "intTernaryOpMaskProvider")
5139     static void BITWISE_BLENDIntMaxVectorTestsAltBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
5140                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
5141         int[] a = fa.apply(SPECIES.length());
5142         int[] b = fb.apply(SPECIES.length());
5143         int[] c = fc.apply(SPECIES.length());
5144         int[] r = fr.apply(SPECIES.length());
5145         boolean[] mask = fm.apply(SPECIES.length());
5146         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5147 
5148         for (int i = 0; i < a.length; i += SPECIES.length()) {
5149             IntVector av = IntVector.fromArray(SPECIES, a, i);
5150             IntVector cv = IntVector.fromArray(SPECIES, c, i);
5151             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], cv, vmask).intoArray(r, i);
5152         }
5153 
5154         assertAltBroadcastArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND);
5155     }
5156 



5157     @Test(dataProvider = "intTernaryOpProvider")
5158     static void BITWISE_BLENDIntMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5159         int[] a = fa.apply(SPECIES.length());
5160         int[] b = fb.apply(SPECIES.length());
5161         int[] c = fc.apply(SPECIES.length());
5162         int[] r = fr.apply(SPECIES.length());
5163 
5164         for (int i = 0; i < a.length; i += SPECIES.length()) {
5165             IntVector av = IntVector.fromArray(SPECIES, a, i);
5166             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i]).intoArray(r, i);
5167         }
5168 
5169         assertDoubleBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::BITWISE_BLEND);
5170     }
5171 
5172     @Test(dataProvider = "intTernaryOpProvider")
5173     static void bitwiseBlendIntMaxVectorTestsDoubleBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb, IntFunction<int[]> fc) {
5174         int[] a = fa.apply(SPECIES.length());
5175         int[] b = fb.apply(SPECIES.length());
5176         int[] c = fc.apply(SPECIES.length());
5177         int[] r = fr.apply(SPECIES.length());
5178 
5179         for (int i = 0; i < a.length; i += SPECIES.length()) {
5180             IntVector av = IntVector.fromArray(SPECIES, a, i);
5181             av.bitwiseBlend(b[i], c[i]).intoArray(r, i);
5182         }
5183 
5184         assertDoubleBroadcastArraysEquals(r, a, b, c, IntMaxVectorTests::bitwiseBlend);
5185     }
5186 

5187     @Test(dataProvider = "intTernaryOpMaskProvider")
5188     static void BITWISE_BLENDIntMaxVectorTestsDoubleBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb,
5189                                           IntFunction<int[]> fc, IntFunction<boolean[]> fm) {
5190         int[] a = fa.apply(SPECIES.length());
5191         int[] b = fb.apply(SPECIES.length());
5192         int[] c = fc.apply(SPECIES.length());
5193         int[] r = fr.apply(SPECIES.length());
5194         boolean[] mask = fm.apply(SPECIES.length());
5195         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5196 
5197         for (int i = 0; i < a.length; i += SPECIES.length()) {
5198             IntVector av = IntVector.fromArray(SPECIES, a, i);
5199             av.lanewise(VectorOperators.BITWISE_BLEND, b[i], c[i], vmask).intoArray(r, i);
5200         }
5201 
5202         assertDoubleBroadcastArraysEquals(r, a, b, c, mask, IntMaxVectorTests::BITWISE_BLEND);
5203     }
5204 

5205     static int NEG(int a) {
5206         return (int)(-((int)a));
5207     }
5208 
5209     static int neg(int a) {
5210         return (int)(-((int)a));
5211     }
5212 
5213     @Test(dataProvider = "intUnaryOpProvider")
5214     static void NEGIntMaxVectorTests(IntFunction<int[]> fa) {
5215         int[] a = fa.apply(SPECIES.length());
5216         int[] r = fr.apply(SPECIES.length());
5217 
5218         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5219             for (int i = 0; i < a.length; i += SPECIES.length()) {
5220                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5221                 av.lanewise(VectorOperators.NEG).intoArray(r, i);
5222             }
5223         }
5224 

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

5317     static int NOT(int a) {
5318         return (int)(~((int)a));
5319     }
5320 
5321     static int not(int a) {
5322         return (int)(~((int)a));
5323     }
5324 


5325     @Test(dataProvider = "intUnaryOpProvider")
5326     static void NOTIntMaxVectorTests(IntFunction<int[]> fa) {
5327         int[] a = fa.apply(SPECIES.length());
5328         int[] r = fr.apply(SPECIES.length());
5329 
5330         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5331             for (int i = 0; i < a.length; i += SPECIES.length()) {
5332                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5333                 av.lanewise(VectorOperators.NOT).intoArray(r, i);
5334             }
5335         }
5336 
5337         assertArraysEquals(r, a, IntMaxVectorTests::NOT);
5338     }
5339 
5340     @Test(dataProvider = "intUnaryOpProvider")
5341     static void notIntMaxVectorTests(IntFunction<int[]> fa) {
5342         int[] a = fa.apply(SPECIES.length());
5343         int[] r = fr.apply(SPECIES.length());
5344 
5345         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5346             for (int i = 0; i < a.length; i += SPECIES.length()) {
5347                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5348                 av.not().intoArray(r, i);
5349             }
5350         }
5351 
5352         assertArraysEquals(r, a, IntMaxVectorTests::not);
5353     }
5354 


5355     @Test(dataProvider = "intUnaryOpMaskProvider")
5356     static void NOTMaskedIntMaxVectorTests(IntFunction<int[]> fa,
5357                                                 IntFunction<boolean[]> fm) {
5358         int[] a = fa.apply(SPECIES.length());
5359         int[] r = fr.apply(SPECIES.length());
5360         boolean[] mask = fm.apply(SPECIES.length());
5361         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5362 
5363         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5364             for (int i = 0; i < a.length; i += SPECIES.length()) {
5365                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5366                 av.lanewise(VectorOperators.NOT, vmask).intoArray(r, i);
5367             }
5368         }
5369 
5370         assertArraysEquals(r, a, mask, IntMaxVectorTests::NOT);
5371     }
5372 


5373     static int ZOMO(int a) {
5374         return (int)((a==0?0:-1));
5375     }
5376 


5377     @Test(dataProvider = "intUnaryOpProvider")
5378     static void ZOMOIntMaxVectorTests(IntFunction<int[]> fa) {
5379         int[] a = fa.apply(SPECIES.length());
5380         int[] r = fr.apply(SPECIES.length());
5381 
5382         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5383             for (int i = 0; i < a.length; i += SPECIES.length()) {
5384                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5385                 av.lanewise(VectorOperators.ZOMO).intoArray(r, i);
5386             }
5387         }
5388 
5389         assertArraysEquals(r, a, IntMaxVectorTests::ZOMO);
5390     }
5391 


5392     @Test(dataProvider = "intUnaryOpMaskProvider")
5393     static void ZOMOMaskedIntMaxVectorTests(IntFunction<int[]> fa,
5394                                                 IntFunction<boolean[]> fm) {
5395         int[] a = fa.apply(SPECIES.length());
5396         int[] r = fr.apply(SPECIES.length());
5397         boolean[] mask = fm.apply(SPECIES.length());
5398         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5399 
5400         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5401             for (int i = 0; i < a.length; i += SPECIES.length()) {
5402                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5403                 av.lanewise(VectorOperators.ZOMO, vmask).intoArray(r, i);
5404             }
5405         }
5406 
5407         assertArraysEquals(r, a, mask, IntMaxVectorTests::ZOMO);
5408     }
5409 
5410     static int BIT_COUNT(int a) {
5411         return (int)(Integer.bitCount(a));
5412     }
5413 
5414     @Test(dataProvider = "intUnaryOpProvider")
5415     static void BIT_COUNTIntMaxVectorTests(IntFunction<int[]> fa) {
5416         int[] a = fa.apply(SPECIES.length());
5417         int[] r = fr.apply(SPECIES.length());
5418 
5419         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5420             for (int i = 0; i < a.length; i += SPECIES.length()) {
5421                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5422                 av.lanewise(VectorOperators.BIT_COUNT).intoArray(r, i);
5423             }
5424         }
5425 
5426         assertArraysEquals(r, a, IntMaxVectorTests::BIT_COUNT);
5427     }
5428 
5429     @Test(dataProvider = "intUnaryOpMaskProvider")
5430     static void BIT_COUNTMaskedIntMaxVectorTests(IntFunction<int[]> fa,
5431                                                 IntFunction<boolean[]> fm) {
5432         int[] a = fa.apply(SPECIES.length());
5433         int[] r = fr.apply(SPECIES.length());
5434         boolean[] mask = fm.apply(SPECIES.length());
5435         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5436 
5437         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5438             for (int i = 0; i < a.length; i += SPECIES.length()) {
5439                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5440                 av.lanewise(VectorOperators.BIT_COUNT, vmask).intoArray(r, i);
5441             }
5442         }
5443 
5444         assertArraysEquals(r, a, mask, IntMaxVectorTests::BIT_COUNT);
5445     }
5446 
5447     static int TRAILING_ZEROS_COUNT(int a) {
5448         return (int)(TRAILING_ZEROS_COUNT_scalar(a));
5449     }
5450 
5451     @Test(dataProvider = "intUnaryOpProvider")
5452     static void TRAILING_ZEROS_COUNTIntMaxVectorTests(IntFunction<int[]> fa) {
5453         int[] a = fa.apply(SPECIES.length());
5454         int[] r = fr.apply(SPECIES.length());
5455 
5456         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5457             for (int i = 0; i < a.length; i += SPECIES.length()) {
5458                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5459                 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT).intoArray(r, i);
5460             }
5461         }
5462 
5463         assertArraysEquals(r, a, IntMaxVectorTests::TRAILING_ZEROS_COUNT);
5464     }
5465 
5466     @Test(dataProvider = "intUnaryOpMaskProvider")
5467     static void TRAILING_ZEROS_COUNTMaskedIntMaxVectorTests(IntFunction<int[]> fa,
5468                                                 IntFunction<boolean[]> fm) {
5469         int[] a = fa.apply(SPECIES.length());
5470         int[] r = fr.apply(SPECIES.length());
5471         boolean[] mask = fm.apply(SPECIES.length());
5472         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5473 
5474         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5475             for (int i = 0; i < a.length; i += SPECIES.length()) {
5476                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5477                 av.lanewise(VectorOperators.TRAILING_ZEROS_COUNT, vmask).intoArray(r, i);
5478             }
5479         }
5480 
5481         assertArraysEquals(r, a, mask, IntMaxVectorTests::TRAILING_ZEROS_COUNT);
5482     }
5483 
5484     static int LEADING_ZEROS_COUNT(int a) {
5485         return (int)(LEADING_ZEROS_COUNT_scalar(a));
5486     }
5487 
5488     @Test(dataProvider = "intUnaryOpProvider")
5489     static void LEADING_ZEROS_COUNTIntMaxVectorTests(IntFunction<int[]> fa) {
5490         int[] a = fa.apply(SPECIES.length());
5491         int[] r = fr.apply(SPECIES.length());
5492 
5493         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5494             for (int i = 0; i < a.length; i += SPECIES.length()) {
5495                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5496                 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT).intoArray(r, i);
5497             }
5498         }
5499 
5500         assertArraysEquals(r, a, IntMaxVectorTests::LEADING_ZEROS_COUNT);
5501     }
5502 
5503     @Test(dataProvider = "intUnaryOpMaskProvider")
5504     static void LEADING_ZEROS_COUNTMaskedIntMaxVectorTests(IntFunction<int[]> fa,
5505                                                 IntFunction<boolean[]> fm) {
5506         int[] a = fa.apply(SPECIES.length());
5507         int[] r = fr.apply(SPECIES.length());
5508         boolean[] mask = fm.apply(SPECIES.length());
5509         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5510 
5511         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5512             for (int i = 0; i < a.length; i += SPECIES.length()) {
5513                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5514                 av.lanewise(VectorOperators.LEADING_ZEROS_COUNT, vmask).intoArray(r, i);
5515             }
5516         }
5517 
5518         assertArraysEquals(r, a, mask, IntMaxVectorTests::LEADING_ZEROS_COUNT);
5519     }
5520 
5521     static int REVERSE(int a) {
5522         return (int)(REVERSE_scalar(a));
5523     }
5524 
5525     @Test(dataProvider = "intUnaryOpProvider")
5526     static void REVERSEIntMaxVectorTests(IntFunction<int[]> fa) {
5527         int[] a = fa.apply(SPECIES.length());
5528         int[] r = fr.apply(SPECIES.length());
5529 
5530         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5531             for (int i = 0; i < a.length; i += SPECIES.length()) {
5532                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5533                 av.lanewise(VectorOperators.REVERSE).intoArray(r, i);
5534             }
5535         }
5536 
5537         assertArraysEquals(r, a, IntMaxVectorTests::REVERSE);
5538     }
5539 
5540     @Test(dataProvider = "intUnaryOpMaskProvider")
5541     static void REVERSEMaskedIntMaxVectorTests(IntFunction<int[]> fa,
5542                                                 IntFunction<boolean[]> fm) {
5543         int[] a = fa.apply(SPECIES.length());
5544         int[] r = fr.apply(SPECIES.length());
5545         boolean[] mask = fm.apply(SPECIES.length());
5546         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5547 
5548         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5549             for (int i = 0; i < a.length; i += SPECIES.length()) {
5550                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5551                 av.lanewise(VectorOperators.REVERSE, vmask).intoArray(r, i);
5552             }
5553         }
5554 
5555         assertArraysEquals(r, a, mask, IntMaxVectorTests::REVERSE);
5556     }
5557 
5558     static int REVERSE_BYTES(int a) {
5559         return (int)(Integer.reverseBytes(a));
5560     }
5561 
5562     @Test(dataProvider = "intUnaryOpProvider")
5563     static void REVERSE_BYTESIntMaxVectorTests(IntFunction<int[]> fa) {
5564         int[] a = fa.apply(SPECIES.length());
5565         int[] r = fr.apply(SPECIES.length());
5566 
5567         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5568             for (int i = 0; i < a.length; i += SPECIES.length()) {
5569                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5570                 av.lanewise(VectorOperators.REVERSE_BYTES).intoArray(r, i);
5571             }
5572         }
5573 
5574         assertArraysEquals(r, a, IntMaxVectorTests::REVERSE_BYTES);
5575     }
5576 
5577     @Test(dataProvider = "intUnaryOpMaskProvider")
5578     static void REVERSE_BYTESMaskedIntMaxVectorTests(IntFunction<int[]> fa,
5579                                                 IntFunction<boolean[]> fm) {
5580         int[] a = fa.apply(SPECIES.length());
5581         int[] r = fr.apply(SPECIES.length());
5582         boolean[] mask = fm.apply(SPECIES.length());
5583         VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
5584 
5585         for (int ic = 0; ic < INVOC_COUNT; ic++) {
5586             for (int i = 0; i < a.length; i += SPECIES.length()) {
5587                 IntVector av = IntVector.fromArray(SPECIES, a, i);
5588                 av.lanewise(VectorOperators.REVERSE_BYTES, vmask).intoArray(r, i);
5589             }
5590         }
5591 
5592         assertArraysEquals(r, a, mask, IntMaxVectorTests::REVERSE_BYTES);
5593     }
5594 
5595     @Test(dataProvider = "intCompareOpProvider")
5596     static void ltIntMaxVectorTestsBroadcastSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
5597         int[] a = fa.apply(SPECIES.length());
5598         int[] b = fb.apply(SPECIES.length());
5599 
5600         for (int i = 0; i < a.length; i += SPECIES.length()) {
5601             IntVector av = IntVector.fromArray(SPECIES, a, i);
5602             VectorMask<Integer> mv = av.lt(b[i]);
5603 
5604             // Check results as part of computation.
5605             for (int j = 0; j < SPECIES.length(); j++) {
5606                 Assert.assertEquals(mv.laneIsSet(j), a[i + j] < b[i]);
5607             }
5608         }
5609     }
5610 
5611     @Test(dataProvider = "intCompareOpProvider")
5612     static void eqIntMaxVectorTestsBroadcastMaskedSmokeTest(IntFunction<int[]> fa, IntFunction<int[]> fb) {
5613         int[] a = fa.apply(SPECIES.length());

5976             }
5977         }
5978         return i - idx;
5979     }
5980 
5981     @Test(dataProvider = "maskProvider")
5982     static void maskFirstTrueIntMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5983         boolean[] a = fa.apply(SPECIES.length());
5984         int[] r = new int[a.length];
5985 
5986         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
5987             for (int i = 0; i < a.length; i += SPECIES.length()) {
5988                 var vmask = SPECIES.loadMask(a, i);
5989                 r[i] = vmask.firstTrue();
5990             }
5991         }
5992 
5993         assertMaskReductionArraysEquals(r, a, IntMaxVectorTests::maskFirstTrue);
5994     }
5995 
5996     @Test(dataProvider = "maskProvider")
5997     static void maskCompressIntMaxVectorTestsSmokeTest(IntFunction<boolean[]> fa) {
5998         int trueCount = 0;
5999         boolean[] a = fa.apply(SPECIES.length());
6000 
6001         for (int ic = 0; ic < INVOC_COUNT * INVOC_COUNT; ic++) {
6002             for (int i = 0; i < a.length; i += SPECIES.length()) {
6003                 var vmask = SPECIES.loadMask(a, i);
6004                 trueCount = vmask.trueCount();
6005                 var rmask = vmask.compress();
6006                 for (int j = 0; j < SPECIES.length(); j++)  {
6007                     Assert.assertEquals(rmask.laneIsSet(j), j < trueCount);
6008                 }
6009             }
6010         }
6011     }
6012 
6013 
6014     @DataProvider
6015     public static Object[][] offsetProvider() {
6016         return new Object[][]{
6017                 {0},
6018                 {-1},
6019                 {+1},
6020                 {+2},
6021                 {-2},
6022         };
6023     }
6024 
6025     @Test(dataProvider = "offsetProvider")
6026     static void indexInRangeIntMaxVectorTestsSmokeTest(int offset) {
6027         int limit = SPECIES.length() * BUFFER_REPS;
6028         for (int i = 0; i < limit; i += SPECIES.length()) {
6029             var actualMask = SPECIES.indexInRange(i + offset, limit);
6030             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
6031             assert(actualMask.equals(expectedMask));
6032             for (int j = 0; j < SPECIES.length(); j++)  {
6033                 int index = i + j + offset;
6034                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
6035             }
6036         }
6037     }
6038 
6039     @Test(dataProvider = "offsetProvider")
6040     static void indexInRangeLongIntMaxVectorTestsSmokeTest(int offset) {
6041         long limit = SPECIES.length() * BUFFER_REPS;
6042         for (long i = 0; i < limit; i += SPECIES.length()) {
6043             var actualMask = SPECIES.indexInRange(i + offset, limit);
6044             var expectedMask = SPECIES.maskAll(true).indexInRange(i + offset, limit);
6045             assert(actualMask.equals(expectedMask));
6046             for (int j = 0; j < SPECIES.length(); j++)  {
6047                 long index = i + j + offset;
6048                 Assert.assertEquals(actualMask.laneIsSet(j), index >= 0 && index < limit);
6049             }
6050         }
6051     }
6052 
6053     @DataProvider
6054     public static Object[][] lengthProvider() {
6055         return new Object[][]{
6056                 {0},
6057                 {1},
6058                 {32},
6059                 {37},
6060                 {1024},
6061                 {1024+1},
6062                 {1024+5},
6063         };
6064     }
6065 
6066     @Test(dataProvider = "lengthProvider")
6067     static void loopBoundIntMaxVectorTestsSmokeTest(int length) {
6068         int actualLoopBound = SPECIES.loopBound(length);
6069         int expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6070         Assert.assertEquals(actualLoopBound, expectedLoopBound);
6071     }
6072 
6073     @Test(dataProvider = "lengthProvider")
6074     static void loopBoundLongIntMaxVectorTestsSmokeTest(int _length) {
6075         long length = _length;
6076         long actualLoopBound = SPECIES.loopBound(length);
6077         long expectedLoopBound = length - Math.floorMod(length, SPECIES.length());
6078         Assert.assertEquals(actualLoopBound, expectedLoopBound);
6079     }
6080 
6081     @Test
6082     static void ElementSizeIntMaxVectorTestsSmokeTest() {
6083         IntVector av = IntVector.zero(SPECIES);
6084         int elsize = av.elementSize();
6085         Assert.assertEquals(elsize, Integer.SIZE);
6086     }
6087 
6088     @Test
6089     static void VectorShapeIntMaxVectorTestsSmokeTest() {
6090         IntVector av = IntVector.zero(SPECIES);
6091         VectorShape vsh = av.shape();
6092         assert(vsh.equals(VectorShape.S_Max_BIT));
6093     }
6094 
6095     @Test
6096     static void ShapeWithLanesIntMaxVectorTestsSmokeTest() {
6097         IntVector av = IntVector.zero(SPECIES);
6098         VectorShape vsh = av.shape();
6099         VectorSpecies species = vsh.withLanes(int.class);
6100         assert(species.equals(SPECIES));

6123         IntVector av = IntVector.zero(SPECIES);
6124         VectorSpecies species = av.species().withLanes(int.class);
6125         assert(species.equals(SPECIES));
6126     }
6127 
6128     @Test
6129     static void WithShapeIntMaxVectorTestsSmokeTest() {
6130         IntVector av = IntVector.zero(SPECIES);
6131         VectorShape vsh = av.shape();
6132         VectorSpecies species = av.species().withShape(vsh);
6133         assert(species.equals(SPECIES));
6134     }
6135 
6136     @Test
6137     static void MaskAllTrueIntMaxVectorTestsSmokeTest() {
6138         for (int ic = 0; ic < INVOC_COUNT; ic++) {
6139           Assert.assertEquals(SPECIES.maskAll(true).toLong(), -1L >>> (64 - SPECIES.length()));
6140         }
6141     }
6142 }

< prev index next >