8291118: [vectorapi] Optimize the implementation of lanewise FIRST_NONZERO
Reviewed-by: eliu, psandoz
This commit is contained in:
parent
38a81913d3
commit
4da1745836
src/jdk.incubator.vector/share/classes/jdk/incubator/vector
@ -759,11 +759,9 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL | VO_SHIFT)) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<Byte> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, (byte) 0);
|
||||
that = that.blend((byte) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
VectorMask<Byte> mask
|
||||
= this.compare(EQ, (byte) 0);
|
||||
return this.blend(that, mask);
|
||||
}
|
||||
if (opKind(op, VO_SHIFT)) {
|
||||
// As per shift specification for Java, mask the shift count.
|
||||
@ -809,11 +807,9 @@ public abstract class ByteVector extends AbstractVector<Byte> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL | VO_SHIFT)) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<Byte> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, (byte) 0);
|
||||
that = that.blend((byte) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
VectorMask<Byte> mask
|
||||
= this.compare(EQ, (byte) 0, m);
|
||||
return this.blend(that, mask);
|
||||
}
|
||||
if (opKind(op, VO_SHIFT)) {
|
||||
// As per shift specification for Java, mask the shift count.
|
||||
|
@ -764,15 +764,9 @@ public abstract class DoubleVector extends AbstractVector<Double> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL )) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<Long> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, (long) 0);
|
||||
that = that.blend((double) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
// FIXME: Support OR_UNCHECKED on float/double also!
|
||||
return this.viewAsIntegralLanes()
|
||||
.lanewise(op, that.viewAsIntegralLanes())
|
||||
.viewAsFloatingLanes();
|
||||
VectorMask<Long> mask
|
||||
= this.viewAsIntegralLanes().compare(EQ, (long) 0);
|
||||
return this.blend(that, mask.cast(vspecies()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -803,7 +797,10 @@ public abstract class DoubleVector extends AbstractVector<Double> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL )) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
return blend(lanewise(op, v), m);
|
||||
LongVector bits = this.viewAsIntegralLanes();
|
||||
VectorMask<Long> mask
|
||||
= bits.compare(EQ, (long) 0, m.cast(bits.vspecies()));
|
||||
return this.blend(that, mask.cast(vspecies()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -764,15 +764,9 @@ public abstract class FloatVector extends AbstractVector<Float> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL )) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<Integer> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, (int) 0);
|
||||
that = that.blend((float) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
// FIXME: Support OR_UNCHECKED on float/double also!
|
||||
return this.viewAsIntegralLanes()
|
||||
.lanewise(op, that.viewAsIntegralLanes())
|
||||
.viewAsFloatingLanes();
|
||||
VectorMask<Integer> mask
|
||||
= this.viewAsIntegralLanes().compare(EQ, (int) 0);
|
||||
return this.blend(that, mask.cast(vspecies()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -803,7 +797,10 @@ public abstract class FloatVector extends AbstractVector<Float> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL )) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
return blend(lanewise(op, v), m);
|
||||
IntVector bits = this.viewAsIntegralLanes();
|
||||
VectorMask<Integer> mask
|
||||
= bits.compare(EQ, (int) 0, m.cast(bits.vspecies()));
|
||||
return this.blend(that, mask.cast(vspecies()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -759,11 +759,9 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL | VO_SHIFT)) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<Integer> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, (int) 0);
|
||||
that = that.blend((int) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
VectorMask<Integer> mask
|
||||
= this.compare(EQ, (int) 0);
|
||||
return this.blend(that, mask);
|
||||
}
|
||||
if (opKind(op, VO_SHIFT)) {
|
||||
// As per shift specification for Java, mask the shift count.
|
||||
@ -809,11 +807,9 @@ public abstract class IntVector extends AbstractVector<Integer> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL | VO_SHIFT)) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<Integer> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, (int) 0);
|
||||
that = that.blend((int) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
VectorMask<Integer> mask
|
||||
= this.compare(EQ, (int) 0, m);
|
||||
return this.blend(that, mask);
|
||||
}
|
||||
if (opKind(op, VO_SHIFT)) {
|
||||
// As per shift specification for Java, mask the shift count.
|
||||
|
@ -717,11 +717,9 @@ public abstract class LongVector extends AbstractVector<Long> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL | VO_SHIFT)) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<Long> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, (long) 0);
|
||||
that = that.blend((long) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
VectorMask<Long> mask
|
||||
= this.compare(EQ, (long) 0);
|
||||
return this.blend(that, mask);
|
||||
}
|
||||
if (opKind(op, VO_SHIFT)) {
|
||||
// As per shift specification for Java, mask the shift count.
|
||||
@ -767,11 +765,9 @@ public abstract class LongVector extends AbstractVector<Long> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL | VO_SHIFT)) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<Long> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, (long) 0);
|
||||
that = that.blend((long) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
VectorMask<Long> mask
|
||||
= this.compare(EQ, (long) 0, m);
|
||||
return this.blend(that, mask);
|
||||
}
|
||||
if (opKind(op, VO_SHIFT)) {
|
||||
// As per shift specification for Java, mask the shift count.
|
||||
|
@ -759,11 +759,9 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL | VO_SHIFT)) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<Short> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, (short) 0);
|
||||
that = that.blend((short) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
VectorMask<Short> mask
|
||||
= this.compare(EQ, (short) 0);
|
||||
return this.blend(that, mask);
|
||||
}
|
||||
if (opKind(op, VO_SHIFT)) {
|
||||
// As per shift specification for Java, mask the shift count.
|
||||
@ -809,11 +807,9 @@ public abstract class ShortVector extends AbstractVector<Short> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL | VO_SHIFT)) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<Short> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, (short) 0);
|
||||
that = that.blend((short) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
VectorMask<Short> mask
|
||||
= this.compare(EQ, (short) 0, m);
|
||||
return this.blend(that, mask);
|
||||
}
|
||||
if (opKind(op, VO_SHIFT)) {
|
||||
// As per shift specification for Java, mask the shift count.
|
||||
|
@ -839,17 +839,9 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
||||
|
||||
if (opKind(op, VO_SPECIAL {#if[!FP]? | VO_SHIFT})) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<$Boxbitstype$> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, ($bitstype$) 0);
|
||||
that = that.blend(($type$) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
#if[FP]
|
||||
// FIXME: Support OR_UNCHECKED on float/double also!
|
||||
return this.viewAsIntegralLanes()
|
||||
.lanewise(op, that.viewAsIntegralLanes())
|
||||
.viewAsFloatingLanes();
|
||||
#end[FP]
|
||||
VectorMask<$Boxbitstype$> mask
|
||||
= this{#if[FP]?.viewAsIntegralLanes()}.compare(EQ, ($bitstype$) 0);
|
||||
return this.blend(that, mask{#if[FP]?.cast(vspecies())});
|
||||
}
|
||||
#if[BITWISE]
|
||||
#if[!FP]
|
||||
@ -900,13 +892,14 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> {
|
||||
if (opKind(op, VO_SPECIAL {#if[!FP]? | VO_SHIFT})) {
|
||||
if (op == FIRST_NONZERO) {
|
||||
#if[FP]
|
||||
return blend(lanewise(op, v), m);
|
||||
$Bitstype$Vector bits = this.viewAsIntegralLanes();
|
||||
VectorMask<$Boxbitstype$> mask
|
||||
= bits.compare(EQ, ($bitstype$) 0, m.cast(bits.vspecies()));
|
||||
return this.blend(that, mask.cast(vspecies()));
|
||||
#else[FP]
|
||||
// FIXME: Support this in the JIT.
|
||||
VectorMask<$Boxbitstype$> thisNZ
|
||||
= this.viewAsIntegralLanes().compare(NE, ($bitstype$) 0);
|
||||
that = that.blend(($type$) 0, thisNZ.cast(vspecies()));
|
||||
op = OR_UNCHECKED;
|
||||
VectorMask<$Boxtype$> mask
|
||||
= this.compare(EQ, ($type$) 0, m);
|
||||
return this.blend(that, mask);
|
||||
#end[FP]
|
||||
}
|
||||
#if[BITWISE]
|
||||
|
Loading…
x
Reference in New Issue
Block a user