8346174: UMAX/UMIN are missing from XXXVector::reductionOperations

Reviewed-by: qamai, jbhateja
This commit is contained in:
Paul Sandoz 2024-12-16 18:53:05 +00:00
parent c75b1d4bf6
commit 31c3b19174
27 changed files with 3586 additions and 1 deletions

View File

@ -1386,8 +1386,9 @@ bool LibraryCallKit::inline_vector_reduction() {
int opc = VectorSupport::vop2ideal(opr->get_con(), elem_bt);
int sopc = ReductionNode::opcode(opc, elem_bt);
// Ensure reduction operation for lanewise operation
// When using mask, mask use type needs to be VecMaskUseLoad.
if (!arch_supports_vector(sopc, num_elem, elem_bt, is_masked_op ? VecMaskUseLoad : VecMaskNotUsed)) {
if (sopc == opc || !arch_supports_vector(sopc, num_elem, elem_bt, is_masked_op ? VecMaskUseLoad : VecMaskNotUsed)) {
log_if_needed(" ** not supported: arity=1 op=%d/reduce vlen=%d etype=%s is_masked_op=%d",
sopc, num_elem, type2name(elem_bt), is_masked_op ? 1 : 0);
return false;

View File

@ -2868,6 +2868,10 @@ public abstract class ByteVector extends AbstractVector<Byte> {
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (byte) Math.min(a, b)));
case VECTOR_OP_MAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (byte) Math.max(a, b)));
case VECTOR_OP_UMIN: return (v, m) ->
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (byte) VectorMath.minUnsigned(a, b)));
case VECTOR_OP_UMAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (byte) VectorMath.maxUnsigned(a, b)));
case VECTOR_OP_AND: return (v, m) ->
toBits(v.rOp((byte)-1, m, (i, a, b) -> (byte)(a & b)));
case VECTOR_OP_OR: return (v, m) ->

View File

@ -2853,6 +2853,10 @@ public abstract class IntVector extends AbstractVector<Integer> {
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (int) Math.min(a, b)));
case VECTOR_OP_MAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (int) Math.max(a, b)));
case VECTOR_OP_UMIN: return (v, m) ->
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (int) VectorMath.minUnsigned(a, b)));
case VECTOR_OP_UMAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (int) VectorMath.maxUnsigned(a, b)));
case VECTOR_OP_AND: return (v, m) ->
toBits(v.rOp((int)-1, m, (i, a, b) -> (int)(a & b)));
case VECTOR_OP_OR: return (v, m) ->

View File

@ -2719,6 +2719,10 @@ public abstract class LongVector extends AbstractVector<Long> {
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (long) Math.min(a, b)));
case VECTOR_OP_MAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (long) Math.max(a, b)));
case VECTOR_OP_UMIN: return (v, m) ->
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (long) VectorMath.minUnsigned(a, b)));
case VECTOR_OP_UMAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (long) VectorMath.maxUnsigned(a, b)));
case VECTOR_OP_AND: return (v, m) ->
toBits(v.rOp((long)-1, m, (i, a, b) -> (long)(a & b)));
case VECTOR_OP_OR: return (v, m) ->

View File

@ -2869,6 +2869,10 @@ public abstract class ShortVector extends AbstractVector<Short> {
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (short) Math.min(a, b)));
case VECTOR_OP_MAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (short) Math.max(a, b)));
case VECTOR_OP_UMIN: return (v, m) ->
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> (short) VectorMath.minUnsigned(a, b)));
case VECTOR_OP_UMAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> (short) VectorMath.maxUnsigned(a, b)));
case VECTOR_OP_AND: return (v, m) ->
toBits(v.rOp((short)-1, m, (i, a, b) -> (short)(a & b)));
case VECTOR_OP_OR: return (v, m) ->

View File

@ -3406,6 +3406,12 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> ($type$) Math.min(a, b)));
case VECTOR_OP_MAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> ($type$) Math.max(a, b)));
#if[!FP]
case VECTOR_OP_UMIN: return (v, m) ->
toBits(v.rOp(MAX_OR_INF, m, (i, a, b) -> ($type$) VectorMath.minUnsigned(a, b)));
case VECTOR_OP_UMAX: return (v, m) ->
toBits(v.rOp(MIN_OR_INF, m, (i, a, b) -> ($type$) VectorMath.maxUnsigned(a, b)));
#end[!FP]
#if[BITWISE]
case VECTOR_OP_AND: return (v, m) ->
toBits(v.rOp(($type$)-1, m, (i, a, b) -> ($type$)(a & b)));

View File

@ -3912,6 +3912,184 @@ public class Byte128VectorTests extends AbstractVectorTest {
Byte128VectorTests::MAXReduceMasked, Byte128VectorTests::MAXReduceAllMasked);
}
static byte UMINReduce(byte[] a, int idx) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static byte UMINReduceAll(byte[] a) {
byte res = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "byteUnaryOpProvider")
static void UMINReduceByte128VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Byte128VectorTests::UMINReduce, Byte128VectorTests::UMINReduceAll);
}
static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static byte UMINReduceAllMasked(byte[] a, boolean[] mask) {
byte res = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void UMINReduceByte128VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
byte ra = Byte.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte128VectorTests::UMINReduceMasked, Byte128VectorTests::UMINReduceAllMasked);
}
static byte UMAXReduce(byte[] a, int idx) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static byte UMAXReduceAll(byte[] a) {
byte res = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "byteUnaryOpProvider")
static void UMAXReduceByte128VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Byte128VectorTests::UMAXReduce, Byte128VectorTests::UMAXReduceAll);
}
static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) {
byte res = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void UMAXReduceByte128VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
byte ra = Byte.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte128VectorTests::UMAXReduceMasked, Byte128VectorTests::UMAXReduceAllMasked);
}
static byte FIRST_NONZEROReduce(byte[] a, int idx) {
byte res = (byte) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3912,6 +3912,184 @@ public class Byte256VectorTests extends AbstractVectorTest {
Byte256VectorTests::MAXReduceMasked, Byte256VectorTests::MAXReduceAllMasked);
}
static byte UMINReduce(byte[] a, int idx) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static byte UMINReduceAll(byte[] a) {
byte res = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "byteUnaryOpProvider")
static void UMINReduceByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Byte256VectorTests::UMINReduce, Byte256VectorTests::UMINReduceAll);
}
static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static byte UMINReduceAllMasked(byte[] a, boolean[] mask) {
byte res = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void UMINReduceByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
byte ra = Byte.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte256VectorTests::UMINReduceMasked, Byte256VectorTests::UMINReduceAllMasked);
}
static byte UMAXReduce(byte[] a, int idx) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static byte UMAXReduceAll(byte[] a) {
byte res = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "byteUnaryOpProvider")
static void UMAXReduceByte256VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Byte256VectorTests::UMAXReduce, Byte256VectorTests::UMAXReduceAll);
}
static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) {
byte res = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void UMAXReduceByte256VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
byte ra = Byte.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte256VectorTests::UMAXReduceMasked, Byte256VectorTests::UMAXReduceAllMasked);
}
static byte FIRST_NONZEROReduce(byte[] a, int idx) {
byte res = (byte) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3912,6 +3912,184 @@ public class Byte512VectorTests extends AbstractVectorTest {
Byte512VectorTests::MAXReduceMasked, Byte512VectorTests::MAXReduceAllMasked);
}
static byte UMINReduce(byte[] a, int idx) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static byte UMINReduceAll(byte[] a) {
byte res = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "byteUnaryOpProvider")
static void UMINReduceByte512VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Byte512VectorTests::UMINReduce, Byte512VectorTests::UMINReduceAll);
}
static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static byte UMINReduceAllMasked(byte[] a, boolean[] mask) {
byte res = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void UMINReduceByte512VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
byte ra = Byte.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte512VectorTests::UMINReduceMasked, Byte512VectorTests::UMINReduceAllMasked);
}
static byte UMAXReduce(byte[] a, int idx) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static byte UMAXReduceAll(byte[] a) {
byte res = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "byteUnaryOpProvider")
static void UMAXReduceByte512VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Byte512VectorTests::UMAXReduce, Byte512VectorTests::UMAXReduceAll);
}
static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) {
byte res = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void UMAXReduceByte512VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
byte ra = Byte.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte512VectorTests::UMAXReduceMasked, Byte512VectorTests::UMAXReduceAllMasked);
}
static byte FIRST_NONZEROReduce(byte[] a, int idx) {
byte res = (byte) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3912,6 +3912,184 @@ public class Byte64VectorTests extends AbstractVectorTest {
Byte64VectorTests::MAXReduceMasked, Byte64VectorTests::MAXReduceAllMasked);
}
static byte UMINReduce(byte[] a, int idx) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static byte UMINReduceAll(byte[] a) {
byte res = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "byteUnaryOpProvider")
static void UMINReduceByte64VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Byte64VectorTests::UMINReduce, Byte64VectorTests::UMINReduceAll);
}
static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static byte UMINReduceAllMasked(byte[] a, boolean[] mask) {
byte res = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void UMINReduceByte64VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
byte ra = Byte.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte64VectorTests::UMINReduceMasked, Byte64VectorTests::UMINReduceAllMasked);
}
static byte UMAXReduce(byte[] a, int idx) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static byte UMAXReduceAll(byte[] a) {
byte res = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "byteUnaryOpProvider")
static void UMAXReduceByte64VectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Byte64VectorTests::UMAXReduce, Byte64VectorTests::UMAXReduceAll);
}
static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) {
byte res = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void UMAXReduceByte64VectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
byte ra = Byte.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Byte64VectorTests::UMAXReduceMasked, Byte64VectorTests::UMAXReduceAllMasked);
}
static byte FIRST_NONZEROReduce(byte[] a, int idx) {
byte res = (byte) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3917,6 +3917,184 @@ public class ByteMaxVectorTests extends AbstractVectorTest {
ByteMaxVectorTests::MAXReduceMasked, ByteMaxVectorTests::MAXReduceAllMasked);
}
static byte UMINReduce(byte[] a, int idx) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static byte UMINReduceAll(byte[] a) {
byte res = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "byteUnaryOpProvider")
static void UMINReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
ByteMaxVectorTests::UMINReduce, ByteMaxVectorTests::UMINReduceAll);
}
static byte UMINReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static byte UMINReduceAllMasked(byte[] a, boolean[] mask) {
byte res = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void UMINReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
byte ra = Byte.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
ByteMaxVectorTests::UMINReduceMasked, ByteMaxVectorTests::UMINReduceAllMasked);
}
static byte UMAXReduce(byte[] a, int idx) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (byte) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static byte UMAXReduceAll(byte[] a) {
byte res = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "byteUnaryOpProvider")
static void UMAXReduceByteMaxVectorTests(IntFunction<byte[]> fa) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
byte ra = Byte.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
ByteMaxVectorTests::UMAXReduce, ByteMaxVectorTests::UMAXReduceAll);
}
static byte UMAXReduceMasked(byte[] a, int idx, boolean[] mask) {
byte res = Byte.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (byte) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static byte UMAXReduceAllMasked(byte[] a, boolean[] mask) {
byte res = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (byte) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "byteUnaryOpMaskProvider")
static void UMAXReduceByteMaxVectorTestsMasked(IntFunction<byte[]> fa, IntFunction<boolean[]> fm) {
byte[] a = fa.apply(SPECIES.length());
byte[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Byte> vmask = VectorMask.fromArray(SPECIES, mask, 0);
byte ra = Byte.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Byte.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ByteVector av = ByteVector.fromArray(SPECIES, a, i);
ra = (byte) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
ByteMaxVectorTests::UMAXReduceMasked, ByteMaxVectorTests::UMAXReduceAllMasked);
}
static byte FIRST_NONZEROReduce(byte[] a, int idx) {
byte res = (byte) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3956,6 +3956,184 @@ public class Int128VectorTests extends AbstractVectorTest {
Int128VectorTests::MAXReduceMasked, Int128VectorTests::MAXReduceAllMasked);
}
static int UMINReduce(int[] a, int idx) {
int res = Integer.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (int) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static int UMINReduceAll(int[] a) {
int res = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "intUnaryOpProvider")
static void UMINReduceInt128VectorTests(IntFunction<int[]> fa) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
int ra = Integer.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Int128VectorTests::UMINReduce, Int128VectorTests::UMINReduceAll);
}
static int UMINReduceMasked(int[] a, int idx, boolean[] mask) {
int res = Integer.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (int) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static int UMINReduceAllMasked(int[] a, boolean[] mask) {
int res = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "intUnaryOpMaskProvider")
static void UMINReduceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
int ra = Integer.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Int128VectorTests::UMINReduceMasked, Int128VectorTests::UMINReduceAllMasked);
}
static int UMAXReduce(int[] a, int idx) {
int res = Integer.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (int) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static int UMAXReduceAll(int[] a) {
int res = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "intUnaryOpProvider")
static void UMAXReduceInt128VectorTests(IntFunction<int[]> fa) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
int ra = Integer.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Int128VectorTests::UMAXReduce, Int128VectorTests::UMAXReduceAll);
}
static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) {
int res = Integer.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (int) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static int UMAXReduceAllMasked(int[] a, boolean[] mask) {
int res = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "intUnaryOpMaskProvider")
static void UMAXReduceInt128VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
int ra = Integer.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Int128VectorTests::UMAXReduceMasked, Int128VectorTests::UMAXReduceAllMasked);
}
static int FIRST_NONZEROReduce(int[] a, int idx) {
int res = (int) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3956,6 +3956,184 @@ public class Int256VectorTests extends AbstractVectorTest {
Int256VectorTests::MAXReduceMasked, Int256VectorTests::MAXReduceAllMasked);
}
static int UMINReduce(int[] a, int idx) {
int res = Integer.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (int) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static int UMINReduceAll(int[] a) {
int res = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "intUnaryOpProvider")
static void UMINReduceInt256VectorTests(IntFunction<int[]> fa) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
int ra = Integer.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Int256VectorTests::UMINReduce, Int256VectorTests::UMINReduceAll);
}
static int UMINReduceMasked(int[] a, int idx, boolean[] mask) {
int res = Integer.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (int) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static int UMINReduceAllMasked(int[] a, boolean[] mask) {
int res = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "intUnaryOpMaskProvider")
static void UMINReduceInt256VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
int ra = Integer.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Int256VectorTests::UMINReduceMasked, Int256VectorTests::UMINReduceAllMasked);
}
static int UMAXReduce(int[] a, int idx) {
int res = Integer.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (int) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static int UMAXReduceAll(int[] a) {
int res = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "intUnaryOpProvider")
static void UMAXReduceInt256VectorTests(IntFunction<int[]> fa) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
int ra = Integer.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Int256VectorTests::UMAXReduce, Int256VectorTests::UMAXReduceAll);
}
static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) {
int res = Integer.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (int) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static int UMAXReduceAllMasked(int[] a, boolean[] mask) {
int res = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "intUnaryOpMaskProvider")
static void UMAXReduceInt256VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
int ra = Integer.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Int256VectorTests::UMAXReduceMasked, Int256VectorTests::UMAXReduceAllMasked);
}
static int FIRST_NONZEROReduce(int[] a, int idx) {
int res = (int) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3956,6 +3956,184 @@ public class Int512VectorTests extends AbstractVectorTest {
Int512VectorTests::MAXReduceMasked, Int512VectorTests::MAXReduceAllMasked);
}
static int UMINReduce(int[] a, int idx) {
int res = Integer.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (int) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static int UMINReduceAll(int[] a) {
int res = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "intUnaryOpProvider")
static void UMINReduceInt512VectorTests(IntFunction<int[]> fa) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
int ra = Integer.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Int512VectorTests::UMINReduce, Int512VectorTests::UMINReduceAll);
}
static int UMINReduceMasked(int[] a, int idx, boolean[] mask) {
int res = Integer.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (int) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static int UMINReduceAllMasked(int[] a, boolean[] mask) {
int res = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "intUnaryOpMaskProvider")
static void UMINReduceInt512VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
int ra = Integer.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Int512VectorTests::UMINReduceMasked, Int512VectorTests::UMINReduceAllMasked);
}
static int UMAXReduce(int[] a, int idx) {
int res = Integer.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (int) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static int UMAXReduceAll(int[] a) {
int res = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "intUnaryOpProvider")
static void UMAXReduceInt512VectorTests(IntFunction<int[]> fa) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
int ra = Integer.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Int512VectorTests::UMAXReduce, Int512VectorTests::UMAXReduceAll);
}
static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) {
int res = Integer.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (int) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static int UMAXReduceAllMasked(int[] a, boolean[] mask) {
int res = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "intUnaryOpMaskProvider")
static void UMAXReduceInt512VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
int ra = Integer.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Int512VectorTests::UMAXReduceMasked, Int512VectorTests::UMAXReduceAllMasked);
}
static int FIRST_NONZEROReduce(int[] a, int idx) {
int res = (int) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3956,6 +3956,184 @@ public class Int64VectorTests extends AbstractVectorTest {
Int64VectorTests::MAXReduceMasked, Int64VectorTests::MAXReduceAllMasked);
}
static int UMINReduce(int[] a, int idx) {
int res = Integer.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (int) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static int UMINReduceAll(int[] a) {
int res = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "intUnaryOpProvider")
static void UMINReduceInt64VectorTests(IntFunction<int[]> fa) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
int ra = Integer.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Int64VectorTests::UMINReduce, Int64VectorTests::UMINReduceAll);
}
static int UMINReduceMasked(int[] a, int idx, boolean[] mask) {
int res = Integer.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (int) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static int UMINReduceAllMasked(int[] a, boolean[] mask) {
int res = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "intUnaryOpMaskProvider")
static void UMINReduceInt64VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
int ra = Integer.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Int64VectorTests::UMINReduceMasked, Int64VectorTests::UMINReduceAllMasked);
}
static int UMAXReduce(int[] a, int idx) {
int res = Integer.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (int) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static int UMAXReduceAll(int[] a) {
int res = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "intUnaryOpProvider")
static void UMAXReduceInt64VectorTests(IntFunction<int[]> fa) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
int ra = Integer.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Int64VectorTests::UMAXReduce, Int64VectorTests::UMAXReduceAll);
}
static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) {
int res = Integer.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (int) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static int UMAXReduceAllMasked(int[] a, boolean[] mask) {
int res = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "intUnaryOpMaskProvider")
static void UMAXReduceInt64VectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
int ra = Integer.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Int64VectorTests::UMAXReduceMasked, Int64VectorTests::UMAXReduceAllMasked);
}
static int FIRST_NONZEROReduce(int[] a, int idx) {
int res = (int) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3961,6 +3961,184 @@ public class IntMaxVectorTests extends AbstractVectorTest {
IntMaxVectorTests::MAXReduceMasked, IntMaxVectorTests::MAXReduceAllMasked);
}
static int UMINReduce(int[] a, int idx) {
int res = Integer.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (int) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static int UMINReduceAll(int[] a) {
int res = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "intUnaryOpProvider")
static void UMINReduceIntMaxVectorTests(IntFunction<int[]> fa) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
int ra = Integer.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
IntMaxVectorTests::UMINReduce, IntMaxVectorTests::UMINReduceAll);
}
static int UMINReduceMasked(int[] a, int idx, boolean[] mask) {
int res = Integer.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (int) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static int UMINReduceAllMasked(int[] a, boolean[] mask) {
int res = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "intUnaryOpMaskProvider")
static void UMINReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
int ra = Integer.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
IntMaxVectorTests::UMINReduceMasked, IntMaxVectorTests::UMINReduceAllMasked);
}
static int UMAXReduce(int[] a, int idx) {
int res = Integer.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (int) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static int UMAXReduceAll(int[] a) {
int res = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "intUnaryOpProvider")
static void UMAXReduceIntMaxVectorTests(IntFunction<int[]> fa) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
int ra = Integer.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
IntMaxVectorTests::UMAXReduce, IntMaxVectorTests::UMAXReduceAll);
}
static int UMAXReduceMasked(int[] a, int idx, boolean[] mask) {
int res = Integer.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (int) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static int UMAXReduceAllMasked(int[] a, boolean[] mask) {
int res = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (int) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "intUnaryOpMaskProvider")
static void UMAXReduceIntMaxVectorTestsMasked(IntFunction<int[]> fa, IntFunction<boolean[]> fm) {
int[] a = fa.apply(SPECIES.length());
int[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Integer> vmask = VectorMask.fromArray(SPECIES, mask, 0);
int ra = Integer.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Integer.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
IntVector av = IntVector.fromArray(SPECIES, a, i);
ra = (int) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
IntMaxVectorTests::UMAXReduceMasked, IntMaxVectorTests::UMAXReduceAllMasked);
}
static int FIRST_NONZEROReduce(int[] a, int idx) {
int res = (int) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3978,6 +3978,184 @@ public class Long128VectorTests extends AbstractVectorTest {
Long128VectorTests::MAXReduceMasked, Long128VectorTests::MAXReduceAllMasked);
}
static long UMINReduce(long[] a, int idx) {
long res = Long.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static long UMINReduceAll(long[] a) {
long res = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider")
static void UMINReduceLong128VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
long ra = Long.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Long128VectorTests::UMINReduce, Long128VectorTests::UMINReduceAll);
}
static long UMINReduceMasked(long[] a, int idx, boolean[] mask) {
long res = Long.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (long) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static long UMINReduceAllMasked(long[] a, boolean[] mask) {
long res = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider")
static void UMINReduceLong128VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
long ra = Long.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long128VectorTests::UMINReduceMasked, Long128VectorTests::UMINReduceAllMasked);
}
static long UMAXReduce(long[] a, int idx) {
long res = Long.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static long UMAXReduceAll(long[] a) {
long res = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider")
static void UMAXReduceLong128VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
long ra = Long.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Long128VectorTests::UMAXReduce, Long128VectorTests::UMAXReduceAll);
}
static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) {
long res = Long.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (long) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static long UMAXReduceAllMasked(long[] a, boolean[] mask) {
long res = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider")
static void UMAXReduceLong128VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
long ra = Long.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long128VectorTests::UMAXReduceMasked, Long128VectorTests::UMAXReduceAllMasked);
}
static long FIRST_NONZEROReduce(long[] a, int idx) {
long res = (long) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3978,6 +3978,184 @@ public class Long256VectorTests extends AbstractVectorTest {
Long256VectorTests::MAXReduceMasked, Long256VectorTests::MAXReduceAllMasked);
}
static long UMINReduce(long[] a, int idx) {
long res = Long.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static long UMINReduceAll(long[] a) {
long res = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider")
static void UMINReduceLong256VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
long ra = Long.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Long256VectorTests::UMINReduce, Long256VectorTests::UMINReduceAll);
}
static long UMINReduceMasked(long[] a, int idx, boolean[] mask) {
long res = Long.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (long) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static long UMINReduceAllMasked(long[] a, boolean[] mask) {
long res = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider")
static void UMINReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
long ra = Long.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long256VectorTests::UMINReduceMasked, Long256VectorTests::UMINReduceAllMasked);
}
static long UMAXReduce(long[] a, int idx) {
long res = Long.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static long UMAXReduceAll(long[] a) {
long res = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider")
static void UMAXReduceLong256VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
long ra = Long.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Long256VectorTests::UMAXReduce, Long256VectorTests::UMAXReduceAll);
}
static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) {
long res = Long.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (long) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static long UMAXReduceAllMasked(long[] a, boolean[] mask) {
long res = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider")
static void UMAXReduceLong256VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
long ra = Long.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long256VectorTests::UMAXReduceMasked, Long256VectorTests::UMAXReduceAllMasked);
}
static long FIRST_NONZEROReduce(long[] a, int idx) {
long res = (long) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3978,6 +3978,184 @@ public class Long512VectorTests extends AbstractVectorTest {
Long512VectorTests::MAXReduceMasked, Long512VectorTests::MAXReduceAllMasked);
}
static long UMINReduce(long[] a, int idx) {
long res = Long.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static long UMINReduceAll(long[] a) {
long res = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider")
static void UMINReduceLong512VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
long ra = Long.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Long512VectorTests::UMINReduce, Long512VectorTests::UMINReduceAll);
}
static long UMINReduceMasked(long[] a, int idx, boolean[] mask) {
long res = Long.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (long) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static long UMINReduceAllMasked(long[] a, boolean[] mask) {
long res = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider")
static void UMINReduceLong512VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
long ra = Long.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long512VectorTests::UMINReduceMasked, Long512VectorTests::UMINReduceAllMasked);
}
static long UMAXReduce(long[] a, int idx) {
long res = Long.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static long UMAXReduceAll(long[] a) {
long res = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider")
static void UMAXReduceLong512VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
long ra = Long.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Long512VectorTests::UMAXReduce, Long512VectorTests::UMAXReduceAll);
}
static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) {
long res = Long.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (long) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static long UMAXReduceAllMasked(long[] a, boolean[] mask) {
long res = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider")
static void UMAXReduceLong512VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
long ra = Long.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long512VectorTests::UMAXReduceMasked, Long512VectorTests::UMAXReduceAllMasked);
}
static long FIRST_NONZEROReduce(long[] a, int idx) {
long res = (long) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3978,6 +3978,184 @@ public class Long64VectorTests extends AbstractVectorTest {
Long64VectorTests::MAXReduceMasked, Long64VectorTests::MAXReduceAllMasked);
}
static long UMINReduce(long[] a, int idx) {
long res = Long.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static long UMINReduceAll(long[] a) {
long res = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider")
static void UMINReduceLong64VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
long ra = Long.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Long64VectorTests::UMINReduce, Long64VectorTests::UMINReduceAll);
}
static long UMINReduceMasked(long[] a, int idx, boolean[] mask) {
long res = Long.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (long) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static long UMINReduceAllMasked(long[] a, boolean[] mask) {
long res = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider")
static void UMINReduceLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
long ra = Long.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long64VectorTests::UMINReduceMasked, Long64VectorTests::UMINReduceAllMasked);
}
static long UMAXReduce(long[] a, int idx) {
long res = Long.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static long UMAXReduceAll(long[] a) {
long res = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider")
static void UMAXReduceLong64VectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
long ra = Long.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Long64VectorTests::UMAXReduce, Long64VectorTests::UMAXReduceAll);
}
static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) {
long res = Long.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (long) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static long UMAXReduceAllMasked(long[] a, boolean[] mask) {
long res = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider")
static void UMAXReduceLong64VectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
long ra = Long.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Long64VectorTests::UMAXReduceMasked, Long64VectorTests::UMAXReduceAllMasked);
}
static long FIRST_NONZEROReduce(long[] a, int idx) {
long res = (long) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3983,6 +3983,184 @@ public class LongMaxVectorTests extends AbstractVectorTest {
LongMaxVectorTests::MAXReduceMasked, LongMaxVectorTests::MAXReduceAllMasked);
}
static long UMINReduce(long[] a, int idx) {
long res = Long.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static long UMINReduceAll(long[] a) {
long res = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider")
static void UMINReduceLongMaxVectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
long ra = Long.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
LongMaxVectorTests::UMINReduce, LongMaxVectorTests::UMINReduceAll);
}
static long UMINReduceMasked(long[] a, int idx, boolean[] mask) {
long res = Long.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (long) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static long UMINReduceAllMasked(long[] a, boolean[] mask) {
long res = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider")
static void UMINReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
long ra = Long.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
LongMaxVectorTests::UMINReduceMasked, LongMaxVectorTests::UMINReduceAllMasked);
}
static long UMAXReduce(long[] a, int idx) {
long res = Long.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (long) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static long UMAXReduceAll(long[] a) {
long res = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "longUnaryOpProvider")
static void UMAXReduceLongMaxVectorTests(IntFunction<long[]> fa) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
long ra = Long.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
LongMaxVectorTests::UMAXReduce, LongMaxVectorTests::UMAXReduceAll);
}
static long UMAXReduceMasked(long[] a, int idx, boolean[] mask) {
long res = Long.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (long) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static long UMAXReduceAllMasked(long[] a, boolean[] mask) {
long res = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (long) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "longUnaryOpMaskProvider")
static void UMAXReduceLongMaxVectorTestsMasked(IntFunction<long[]> fa, IntFunction<boolean[]> fm) {
long[] a = fa.apply(SPECIES.length());
long[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Long> vmask = VectorMask.fromArray(SPECIES, mask, 0);
long ra = Long.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Long.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
LongVector av = LongVector.fromArray(SPECIES, a, i);
ra = (long) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
LongMaxVectorTests::UMAXReduceMasked, LongMaxVectorTests::UMAXReduceAllMasked);
}
static long FIRST_NONZEROReduce(long[] a, int idx) {
long res = (long) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3903,6 +3903,184 @@ public class Short128VectorTests extends AbstractVectorTest {
Short128VectorTests::MAXReduceMasked, Short128VectorTests::MAXReduceAllMasked);
}
static short UMINReduce(short[] a, int idx) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static short UMINReduceAll(short[] a) {
short res = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "shortUnaryOpProvider")
static void UMINReduceShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Short128VectorTests::UMINReduce, Short128VectorTests::UMINReduceAll);
}
static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static short UMINReduceAllMasked(short[] a, boolean[] mask) {
short res = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void UMINReduceShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
short ra = Short.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short128VectorTests::UMINReduceMasked, Short128VectorTests::UMINReduceAllMasked);
}
static short UMAXReduce(short[] a, int idx) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static short UMAXReduceAll(short[] a) {
short res = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "shortUnaryOpProvider")
static void UMAXReduceShort128VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Short128VectorTests::UMAXReduce, Short128VectorTests::UMAXReduceAll);
}
static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
short res = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void UMAXReduceShort128VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
short ra = Short.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short128VectorTests::UMAXReduceMasked, Short128VectorTests::UMAXReduceAllMasked);
}
static short FIRST_NONZEROReduce(short[] a, int idx) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3903,6 +3903,184 @@ public class Short256VectorTests extends AbstractVectorTest {
Short256VectorTests::MAXReduceMasked, Short256VectorTests::MAXReduceAllMasked);
}
static short UMINReduce(short[] a, int idx) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static short UMINReduceAll(short[] a) {
short res = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "shortUnaryOpProvider")
static void UMINReduceShort256VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Short256VectorTests::UMINReduce, Short256VectorTests::UMINReduceAll);
}
static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static short UMINReduceAllMasked(short[] a, boolean[] mask) {
short res = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void UMINReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
short ra = Short.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short256VectorTests::UMINReduceMasked, Short256VectorTests::UMINReduceAllMasked);
}
static short UMAXReduce(short[] a, int idx) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static short UMAXReduceAll(short[] a) {
short res = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "shortUnaryOpProvider")
static void UMAXReduceShort256VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Short256VectorTests::UMAXReduce, Short256VectorTests::UMAXReduceAll);
}
static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
short res = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void UMAXReduceShort256VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
short ra = Short.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short256VectorTests::UMAXReduceMasked, Short256VectorTests::UMAXReduceAllMasked);
}
static short FIRST_NONZEROReduce(short[] a, int idx) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3903,6 +3903,184 @@ public class Short512VectorTests extends AbstractVectorTest {
Short512VectorTests::MAXReduceMasked, Short512VectorTests::MAXReduceAllMasked);
}
static short UMINReduce(short[] a, int idx) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static short UMINReduceAll(short[] a) {
short res = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "shortUnaryOpProvider")
static void UMINReduceShort512VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Short512VectorTests::UMINReduce, Short512VectorTests::UMINReduceAll);
}
static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static short UMINReduceAllMasked(short[] a, boolean[] mask) {
short res = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void UMINReduceShort512VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
short ra = Short.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short512VectorTests::UMINReduceMasked, Short512VectorTests::UMINReduceAllMasked);
}
static short UMAXReduce(short[] a, int idx) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static short UMAXReduceAll(short[] a) {
short res = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "shortUnaryOpProvider")
static void UMAXReduceShort512VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Short512VectorTests::UMAXReduce, Short512VectorTests::UMAXReduceAll);
}
static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
short res = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void UMAXReduceShort512VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
short ra = Short.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short512VectorTests::UMAXReduceMasked, Short512VectorTests::UMAXReduceAllMasked);
}
static short FIRST_NONZEROReduce(short[] a, int idx) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3903,6 +3903,184 @@ public class Short64VectorTests extends AbstractVectorTest {
Short64VectorTests::MAXReduceMasked, Short64VectorTests::MAXReduceAllMasked);
}
static short UMINReduce(short[] a, int idx) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static short UMINReduceAll(short[] a) {
short res = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "shortUnaryOpProvider")
static void UMINReduceShort64VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
Short64VectorTests::UMINReduce, Short64VectorTests::UMINReduceAll);
}
static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static short UMINReduceAllMasked(short[] a, boolean[] mask) {
short res = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void UMINReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
short ra = Short.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short64VectorTests::UMINReduceMasked, Short64VectorTests::UMINReduceAllMasked);
}
static short UMAXReduce(short[] a, int idx) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static short UMAXReduceAll(short[] a) {
short res = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "shortUnaryOpProvider")
static void UMAXReduceShort64VectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
Short64VectorTests::UMAXReduce, Short64VectorTests::UMAXReduceAll);
}
static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
short res = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void UMAXReduceShort64VectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
short ra = Short.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
Short64VectorTests::UMAXReduceMasked, Short64VectorTests::UMAXReduceAllMasked);
}
static short FIRST_NONZEROReduce(short[] a, int idx) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -3908,6 +3908,184 @@ public class ShortMaxVectorTests extends AbstractVectorTest {
ShortMaxVectorTests::MAXReduceMasked, ShortMaxVectorTests::MAXReduceAllMasked);
}
static short UMINReduce(short[] a, int idx) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static short UMINReduceAll(short[] a) {
short res = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.minUnsigned(res, UMINReduce(a, i));
}
return res;
}
@Test(dataProvider = "shortUnaryOpProvider")
static void UMINReduceShortMaxVectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN));
}
}
assertReductionArraysEquals(r, ra, a,
ShortMaxVectorTests::UMINReduce, ShortMaxVectorTests::UMINReduceAll);
}
static short UMINReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MAX_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) VectorMath.minUnsigned(res, a[i]);
}
return res;
}
static short UMINReduceAllMasked(short[] a, boolean[] mask) {
short res = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.minUnsigned(res, UMINReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void UMINReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
short ra = Short.MAX_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMIN, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MAX_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.minUnsigned(ra, av.reduceLanes(VectorOperators.UMIN, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
ShortMaxVectorTests::UMINReduceMasked, ShortMaxVectorTests::UMINReduceAllMasked);
}
static short UMAXReduce(short[] a, int idx) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
res = (short) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static short UMAXReduceAll(short[] a) {
short res = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.maxUnsigned(res, UMAXReduce(a, i));
}
return res;
}
@Test(dataProvider = "shortUnaryOpProvider")
static void UMAXReduceShortMaxVectorTests(IntFunction<short[]> fa) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
short ra = Short.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX));
}
}
assertReductionArraysEquals(r, ra, a,
ShortMaxVectorTests::UMAXReduce, ShortMaxVectorTests::UMAXReduceAll);
}
static short UMAXReduceMasked(short[] a, int idx, boolean[] mask) {
short res = Short.MIN_VALUE;
for (int i = idx; i < (idx + SPECIES.length()); i++) {
if (mask[i % SPECIES.length()])
res = (short) VectorMath.maxUnsigned(res, a[i]);
}
return res;
}
static short UMAXReduceAllMasked(short[] a, boolean[] mask) {
short res = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
res = (short) VectorMath.maxUnsigned(res, UMAXReduceMasked(a, i, mask));
}
return res;
}
@Test(dataProvider = "shortUnaryOpMaskProvider")
static void UMAXReduceShortMaxVectorTestsMasked(IntFunction<short[]> fa, IntFunction<boolean[]> fm) {
short[] a = fa.apply(SPECIES.length());
short[] r = fr.apply(SPECIES.length());
boolean[] mask = fm.apply(SPECIES.length());
VectorMask<Short> vmask = VectorMask.fromArray(SPECIES, mask, 0);
short ra = Short.MIN_VALUE;
for (int ic = 0; ic < INVOC_COUNT; ic++) {
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
r[i] = av.reduceLanes(VectorOperators.UMAX, vmask);
}
}
for (int ic = 0; ic < INVOC_COUNT; ic++) {
ra = Short.MIN_VALUE;
for (int i = 0; i < a.length; i += SPECIES.length()) {
ShortVector av = ShortVector.fromArray(SPECIES, a, i);
ra = (short) VectorMath.maxUnsigned(ra, av.reduceLanes(VectorOperators.UMAX, vmask));
}
}
assertReductionArraysEqualsMasked(r, ra, a, mask,
ShortMaxVectorTests::UMAXReduceMasked, ShortMaxVectorTests::UMAXReduceAllMasked);
}
static short FIRST_NONZEROReduce(short[] a, int idx) {
short res = (short) 0;
for (int i = idx; i < (idx + SPECIES.length()); i++) {

View File

@ -484,6 +484,8 @@ gen_reduction_op "ADD" "+" "" "0"
gen_reduction_op "MUL" "*" "" "1"
gen_reduction_op_func "MIN" "(\$type\$) Math.min" "" "\$Wideboxtype\$.\$MaxValue\$"
gen_reduction_op_func "MAX" "(\$type\$) Math.max" "" "\$Wideboxtype\$.\$MinValue\$"
gen_reduction_op_func "UMIN" "(\$type\$) VectorMath.minUnsigned" "BITWISE" "\$Wideboxtype\$.\$MaxValue\$"
gen_reduction_op_func "UMAX" "(\$type\$) VectorMath.maxUnsigned" "BITWISE" "\$Wideboxtype\$.\$MinValue\$"
gen_reduction_op_func "FIRST_NONZERO" "firstNonZero" "" "(\$type\$) 0"
# Boolean reductions.