< prev index next > src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorIntrinsics.java
Print this page
case 2: return Objects.checkIndex(ix, length - (vlen - 1));
default: throw new InternalError();
}
}
+ @ForceInline
+ static long checkFromIndexSize(long ix, long vlen, long length) {
+ switch (VectorIntrinsics.VECTOR_ACCESS_OOB_CHECK) {
+ case 0: return ix; // no range check
+ case 1: return Objects.checkFromIndexSize(ix, vlen, length);
+ case 2: return Objects.checkIndex(ix, length - (vlen - 1));
+ default: throw new InternalError();
+ }
+ }
+
@ForceInline
static IntVector checkIndex(IntVector vix, int length) {
switch (VectorIntrinsics.VECTOR_ACCESS_OOB_CHECK) {
case 0: return vix; // no range check
case 1: // fall-through
}
private static int roundDownNPOT(int index, int size) {
if (index >= 0) {
return index - (index % size);
} else {
- return index - Math.floorMod(index, Math.abs(size));
+ return index - Math.floorMod(index, size);
}
}
+
+ // If the index is not already a multiple of size,
+ // round it down to the next smaller multiple of size.
+ // It is an error if size is less than zero.
+ @ForceInline
+ static long roundDown(long index, int size) {
+ if ((size & (size - 1)) == 0) {
+ // Size is zero or a power of two, so we got this.
+ return index & ~(size - 1);
+ } else {
+ return roundDownNPOT(index, size);
+ }
+ }
+ private static long roundDownNPOT(long index, int size) {
+ if (index >= 0) {
+ return index - (index % size);
+ } else {
+ return index - Math.floorMod(index, size);
+ }
+ }
+
@ForceInline
static int wrapToRange(int index, int size) {
if ((size & (size - 1)) == 0) {
// Size is zero or a power of two, so we got this.
return index & (size - 1);
< prev index next >