diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java index efa18066482cd..93febadf3e397 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double128Vector.java @@ -805,13 +805,31 @@ public int laneSource(int i) { @Override @ForceInline public void intoArray(int[] a, int offset) { - VectorSpecies<Integer> species = VectorSpecies.of( - int.class, - VectorShape.forBitSize(length() * Integer.SIZE)); - Vector<Long> v = toBitsVector(); - v.convertShape(VectorOperators.L2I, species, 0) - .reinterpretAsInts() - .intoArray(a, offset); + switch (length()) { + case 1 -> a[offset] = laneSource(0); + case 2 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 4 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 8 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 16 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0) + .reinterpretAsInts() + .intoArray(a, offset); + default -> { + VectorIntrinsics.checkFromIndexSize(offset, length(), a.length); + for (int i = 0; i < length(); i++) { + a[offset + i] = laneSource(i); + } + } + } } private static long[] prepare(int[] indices, int offset) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java index 10677e59830bb..6b0b847f4856f 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double256Vector.java @@ -809,13 +809,31 @@ public int laneSource(int i) { @Override @ForceInline public void intoArray(int[] a, int offset) { - VectorSpecies<Integer> species = VectorSpecies.of( - int.class, - VectorShape.forBitSize(length() * Integer.SIZE)); - Vector<Long> v = toBitsVector(); - v.convertShape(VectorOperators.L2I, species, 0) - .reinterpretAsInts() - .intoArray(a, offset); + switch (length()) { + case 1 -> a[offset] = laneSource(0); + case 2 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 4 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 8 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 16 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0) + .reinterpretAsInts() + .intoArray(a, offset); + default -> { + VectorIntrinsics.checkFromIndexSize(offset, length(), a.length); + for (int i = 0; i < length(); i++) { + a[offset + i] = laneSource(i); + } + } + } } private static long[] prepare(int[] indices, int offset) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java index 80762d040198a..addbc17c14f51 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double512Vector.java @@ -817,13 +817,31 @@ public int laneSource(int i) { @Override @ForceInline public void intoArray(int[] a, int offset) { - VectorSpecies<Integer> species = VectorSpecies.of( - int.class, - VectorShape.forBitSize(length() * Integer.SIZE)); - Vector<Long> v = toBitsVector(); - v.convertShape(VectorOperators.L2I, species, 0) - .reinterpretAsInts() - .intoArray(a, offset); + switch (length()) { + case 1 -> a[offset] = laneSource(0); + case 2 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 4 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 8 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 16 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0) + .reinterpretAsInts() + .intoArray(a, offset); + default -> { + VectorIntrinsics.checkFromIndexSize(offset, length(), a.length); + for (int i = 0; i < length(); i++) { + a[offset + i] = laneSource(i); + } + } + } } private static long[] prepare(int[] indices, int offset) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java index aca9f2b65e8ad..c7e41bd382dde 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java @@ -803,7 +803,31 @@ public int laneSource(int i) { @Override @ForceInline public void intoArray(int[] a, int offset) { - a[offset] = laneSource(0); + switch (length()) { + case 1 -> a[offset] = laneSource(0); + case 2 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 4 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 8 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 16 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0) + .reinterpretAsInts() + .intoArray(a, offset); + default -> { + VectorIntrinsics.checkFromIndexSize(offset, length(), a.length); + for (int i = 0; i < length(); i++) { + a[offset + i] = laneSource(i); + } + } + } } private static long[] prepare(int[] indices, int offset) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java index 54b593b8129b4..61dea4bcf8b5a 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleMaxVector.java @@ -802,13 +802,31 @@ public int laneSource(int i) { @Override @ForceInline public void intoArray(int[] a, int offset) { - VectorSpecies<Integer> species = VectorSpecies.of( - int.class, - VectorShape.forBitSize(length() * Integer.SIZE)); - Vector<Long> v = toBitsVector(); - v.convertShape(VectorOperators.L2I, species, 0) - .reinterpretAsInts() - .intoArray(a, offset); + switch (length()) { + case 1 -> a[offset] = laneSource(0); + case 2 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 4 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 8 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 16 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0) + .reinterpretAsInts() + .intoArray(a, offset); + default -> { + VectorIntrinsics.checkFromIndexSize(offset, length(), a.length); + for (int i = 0; i < length(); i++) { + a[offset + i] = laneSource(i); + } + } + } } private static long[] prepare(int[] indices, int offset) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java index 9aa24fe471dc8..87d5bc3625348 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long128Vector.java @@ -806,13 +806,31 @@ public int laneSource(int i) { @Override @ForceInline public void intoArray(int[] a, int offset) { - VectorSpecies<Integer> species = VectorSpecies.of( - int.class, - VectorShape.forBitSize(length() * Integer.SIZE)); - Vector<Long> v = toBitsVector(); - v.convertShape(VectorOperators.L2I, species, 0) - .reinterpretAsInts() - .intoArray(a, offset); + switch (length()) { + case 1 -> a[offset] = laneSource(0); + case 2 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 4 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 8 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 16 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0) + .reinterpretAsInts() + .intoArray(a, offset); + default -> { + VectorIntrinsics.checkFromIndexSize(offset, length(), a.length); + for (int i = 0; i < length(); i++) { + a[offset + i] = laneSource(i); + } + } + } } private static long[] prepare(int[] indices, int offset) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java index 498118027c855..4de92041ea8f6 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long256Vector.java @@ -810,13 +810,31 @@ public int laneSource(int i) { @Override @ForceInline public void intoArray(int[] a, int offset) { - VectorSpecies<Integer> species = VectorSpecies.of( - int.class, - VectorShape.forBitSize(length() * Integer.SIZE)); - Vector<Long> v = toBitsVector(); - v.convertShape(VectorOperators.L2I, species, 0) - .reinterpretAsInts() - .intoArray(a, offset); + switch (length()) { + case 1 -> a[offset] = laneSource(0); + case 2 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 4 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 8 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 16 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0) + .reinterpretAsInts() + .intoArray(a, offset); + default -> { + VectorIntrinsics.checkFromIndexSize(offset, length(), a.length); + for (int i = 0; i < length(); i++) { + a[offset + i] = laneSource(i); + } + } + } } private static long[] prepare(int[] indices, int offset) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java index bd3edf3a29778..5bbe81f4c7c22 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long512Vector.java @@ -818,13 +818,31 @@ public int laneSource(int i) { @Override @ForceInline public void intoArray(int[] a, int offset) { - VectorSpecies<Integer> species = VectorSpecies.of( - int.class, - VectorShape.forBitSize(length() * Integer.SIZE)); - Vector<Long> v = toBitsVector(); - v.convertShape(VectorOperators.L2I, species, 0) - .reinterpretAsInts() - .intoArray(a, offset); + switch (length()) { + case 1 -> a[offset] = laneSource(0); + case 2 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 4 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 8 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 16 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0) + .reinterpretAsInts() + .intoArray(a, offset); + default -> { + VectorIntrinsics.checkFromIndexSize(offset, length(), a.length); + for (int i = 0; i < length(); i++) { + a[offset + i] = laneSource(i); + } + } + } } private static long[] prepare(int[] indices, int offset) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java index ce954591e4a22..cf0246f670e75 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Long64Vector.java @@ -804,7 +804,31 @@ public int laneSource(int i) { @Override @ForceInline public void intoArray(int[] a, int offset) { - a[offset] = laneSource(0); + switch (length()) { + case 1 -> a[offset] = laneSource(0); + case 2 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 4 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 8 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 16 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0) + .reinterpretAsInts() + .intoArray(a, offset); + default -> { + VectorIntrinsics.checkFromIndexSize(offset, length(), a.length); + for (int i = 0; i < length(); i++) { + a[offset + i] = laneSource(i); + } + } + } } private static long[] prepare(int[] indices, int offset) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java index 3bc9a8992fa89..54a8cb6537c0a 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongMaxVector.java @@ -804,13 +804,31 @@ public int laneSource(int i) { @Override @ForceInline public void intoArray(int[] a, int offset) { - VectorSpecies<Integer> species = VectorSpecies.of( - int.class, - VectorShape.forBitSize(length() * Integer.SIZE)); - Vector<Long> v = toBitsVector(); - v.convertShape(VectorOperators.L2I, species, 0) - .reinterpretAsInts() - .intoArray(a, offset); + switch (length()) { + case 1 -> a[offset] = laneSource(0); + case 2 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 4 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 8 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 16 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0) + .reinterpretAsInts() + .intoArray(a, offset); + default -> { + VectorIntrinsics.checkFromIndexSize(offset, length(), a.length); + for (int i = 0; i < length(); i++) { + a[offset + i] = laneSource(i); + } + } + } } private static long[] prepare(int[] indices, int offset) { diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template index a22d526427d20..8f0632a8b7386 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-VectorBits.java.template @@ -1132,18 +1132,31 @@ final class $vectortype$ extends $abstractvectortype$ { toBitsVector().intoArray(a, offset); #end[intOrFloat] #if[longOrDouble] -#if[!1L] - VectorSpecies<Integer> species = VectorSpecies.of( - int.class, - VectorShape.forBitSize(length() * Integer.SIZE)); - Vector<Long> v = toBitsVector(); - v.convertShape(VectorOperators.L2I, species, 0) - .reinterpretAsInts() - .intoArray(a, offset); -#end[!1L] -#if[1L] - a[offset] = laneSource(0); -#end[1L] + switch (length()) { + case 1 -> a[offset] = laneSource(0); + case 2 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_64, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 4 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_128, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 8 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_256, 0) + .reinterpretAsInts() + .intoArray(a, offset); + case 16 -> toBitsVector() + .convertShape(VectorOperators.L2I, IntVector.SPECIES_512, 0) + .reinterpretAsInts() + .intoArray(a, offset); + default -> { + VectorIntrinsics.checkFromIndexSize(offset, length(), a.length); + for (int i = 0; i < length(); i++) { + a[offset + i] = laneSource(i); + } + } + } #end[longOrDouble] }