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