From c275318ab11ca61da0fa87b6951dcf56d3095c49 Mon Sep 17 00:00:00 2001 From: "Jin,Zhonghui" Date: Fri, 3 Nov 2023 00:58:26 +0800 Subject: [PATCH] [Backport] 8265128: [REDO] Optimize Vector API slice and unslice operations Summary: 8265128: [REDO] Optimize Vector API slice and unslice operations Test Plan: ci jtreg Reviewed-by: JoshuaZhuwj Issue: https://github.com/dragonwell-project/dragonwell11/issues/598 --- .../jdk/incubator/vector/Byte128Vector.java | 20 +------ .../jdk/incubator/vector/Byte256Vector.java | 20 +------ .../jdk/incubator/vector/Byte512Vector.java | 20 +------ .../jdk/incubator/vector/Byte64Vector.java | 20 +------ .../jdk/incubator/vector/ByteMaxVector.java | 20 +------ .../jdk/incubator/vector/ByteVector.java | 58 +++++++++++-------- .../jdk/incubator/vector/Double128Vector.java | 20 +------ .../jdk/incubator/vector/Double256Vector.java | 20 +------ .../jdk/incubator/vector/Double512Vector.java | 20 +------ .../jdk/incubator/vector/Double64Vector.java | 20 +------ .../jdk/incubator/vector/DoubleMaxVector.java | 20 +------ .../jdk/incubator/vector/DoubleVector.java | 58 +++++++++++-------- .../jdk/incubator/vector/Float128Vector.java | 20 +------ .../jdk/incubator/vector/Float256Vector.java | 20 +------ .../jdk/incubator/vector/Float512Vector.java | 20 +------ .../jdk/incubator/vector/Float64Vector.java | 20 +------ .../jdk/incubator/vector/FloatMaxVector.java | 20 +------ .../jdk/incubator/vector/FloatVector.java | 58 +++++++++++-------- .../jdk/incubator/vector/Int128Vector.java | 20 +------ .../jdk/incubator/vector/Int256Vector.java | 20 +------ .../jdk/incubator/vector/Int512Vector.java | 20 +------ .../jdk/incubator/vector/Int64Vector.java | 20 +------ .../jdk/incubator/vector/IntMaxVector.java | 20 +------ .../jdk/incubator/vector/IntVector.java | 58 +++++++++++-------- .../jdk/incubator/vector/Long128Vector.java | 20 +------ .../jdk/incubator/vector/Long256Vector.java | 20 +------ .../jdk/incubator/vector/Long512Vector.java | 20 +------ .../jdk/incubator/vector/Long64Vector.java | 20 +------ .../jdk/incubator/vector/LongMaxVector.java | 20 +------ .../jdk/incubator/vector/LongVector.java | 58 +++++++++++-------- .../jdk/incubator/vector/Short128Vector.java | 20 +------ .../jdk/incubator/vector/Short256Vector.java | 20 +------ .../jdk/incubator/vector/Short512Vector.java | 20 +------ .../jdk/incubator/vector/Short64Vector.java | 20 +------ .../jdk/incubator/vector/ShortMaxVector.java | 20 +------ .../jdk/incubator/vector/ShortVector.java | 58 +++++++++++-------- .../incubator/vector/X-Vector.java.template | 58 +++++++++++-------- .../vector/X-VectorBits.java.template | 20 +------ .../vector/AbstractVectorConversionTest.java | 4 +- .../vector/Vector128ConversionTests.java | 11 ++-- .../vector/Vector256ConversionTests.java | 11 ++-- .../vector/Vector512ConversionTests.java | 11 ++-- .../vector/Vector64ConversionTests.java | 9 +-- 43 files changed, 363 insertions(+), 709 deletions(-) diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java index 4c422e1ec1c..e2baacff09d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Byte128Vector slice(int origin, Vector v) { @Override @ForceInline public Byte128Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Byte128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((byte)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Byte128Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Byte128Vector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Byte128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((byte)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Byte128Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java index 7267b83cf0f..f100935e6f0 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Byte256Vector slice(int origin, Vector v) { @Override @ForceInline public Byte256Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Byte256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((byte)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Byte256Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Byte256Vector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Byte256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((byte)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Byte256Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java index a16f0e6055c..70a23a22fd1 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Byte512Vector slice(int origin, Vector v) { @Override @ForceInline public Byte512Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Byte512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((byte)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Byte512Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Byte512Vector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Byte512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((byte)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Byte512Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java index ea7506489d9..e33be0fb12c 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Byte64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Byte64Vector slice(int origin, Vector v) { @Override @ForceInline public Byte64Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Byte64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((byte)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Byte64Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Byte64Vector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Byte64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((byte)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Byte64Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java index 6288ffaf72d..19ec4bf57e6 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public ByteMaxVector slice(int origin, Vector v) { @Override @ForceInline public ByteMaxVector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - ByteMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((byte)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (ByteMaxVector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public ByteMaxVector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - ByteMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((byte)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (ByteMaxVector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java index de090ca9686..a50fb8123ff 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java @@ -1981,14 +1981,11 @@ public final ByteVector blend(long e, ByteVector sliceTemplate(int origin, Vector v1) { ByteVector that = (ByteVector) v1; that.check(this); - byte[] a0 = this.vec(); - byte[] a1 = that.vec(); - byte[] res = new byte[a0.length]; - int vlen = res.length; - int firstPart = vlen - origin; - System.arraycopy(a0, origin, res, 0, firstPart); - System.arraycopy(a1, 0, res, firstPart, origin); - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((byte)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return that.rearrange(iota).blend(this.rearrange(iota), blendMask); } /** @@ -2010,6 +2007,17 @@ ByteVector slice(int origin, public abstract ByteVector slice(int origin); + /*package-private*/ + final + @ForceInline + ByteVector sliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((byte)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + /** * {@inheritDoc} */ @@ -2024,21 +2032,12 @@ ByteVector slice(int origin, unsliceTemplate(int origin, Vector w, int part) { ByteVector that = (ByteVector) w; that.check(this); - byte[] slice = this.vec(); - byte[] res = that.vec().clone(); - int vlen = res.length; - int firstPart = vlen - origin; - switch (part) { - case 0: - System.arraycopy(slice, 0, res, origin, firstPart); - break; - case 1: - System.arraycopy(slice, firstPart, res, 0, origin); - break; - default: - throw wrongPartForSlice(part); - } - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare((part == 0) ? VectorOperators.GE : VectorOperators.LT, + (broadcast((byte)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return that.blend(this.rearrange(iota), blendMask); } /*package-private*/ @@ -2068,6 +2067,19 @@ ByteVector slice(int origin, public abstract ByteVector unslice(int origin); + /*package-private*/ + final + @ForceInline + ByteVector + unsliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.GE, + (broadcast((byte)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + private ArrayIndexOutOfBoundsException wrongPartForSlice(int part) { String msg = String.format("bad part number %d for slice operation", 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 6294f995ecb..6df75dec501 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -381,14 +381,7 @@ public Double128Vector slice(int origin, Vector v) { @Override @ForceInline public Double128Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Double128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((double)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Double128Vector) super.sliceTemplate(origin); // specialize } @Override @@ -409,14 +402,7 @@ public Double128Vector unslice(int origin, Vector w, int part, VectorMas @Override @ForceInline public Double128Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Double128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((double)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Double128Vector) super.unsliceTemplate(origin); // specialize } @Override 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 27656383a72..d4058fb25f7 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -381,14 +381,7 @@ public Double256Vector slice(int origin, Vector v) { @Override @ForceInline public Double256Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Double256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((double)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Double256Vector) super.sliceTemplate(origin); // specialize } @Override @@ -409,14 +402,7 @@ public Double256Vector unslice(int origin, Vector w, int part, VectorMas @Override @ForceInline public Double256Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Double256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((double)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Double256Vector) super.unsliceTemplate(origin); // specialize } @Override 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 4e9b3f6e996..04f27791871 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -381,14 +381,7 @@ public Double512Vector slice(int origin, Vector v) { @Override @ForceInline public Double512Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Double512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((double)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Double512Vector) super.sliceTemplate(origin); // specialize } @Override @@ -409,14 +402,7 @@ public Double512Vector unslice(int origin, Vector w, int part, VectorMas @Override @ForceInline public Double512Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Double512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((double)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Double512Vector) super.unsliceTemplate(origin); // specialize } @Override 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 91234cbf04a..14672601009 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -381,14 +381,7 @@ public Double64Vector slice(int origin, Vector v) { @Override @ForceInline public Double64Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Double64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((double)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Double64Vector) super.sliceTemplate(origin); // specialize } @Override @@ -409,14 +402,7 @@ public Double64Vector unslice(int origin, Vector w, int part, VectorMask @Override @ForceInline public Double64Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Double64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((double)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Double64Vector) super.unsliceTemplate(origin); // specialize } @Override 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 436eaaf7dde..54b5a9f4805 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -381,14 +381,7 @@ public DoubleMaxVector slice(int origin, Vector v) { @Override @ForceInline public DoubleMaxVector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - DoubleMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((double)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (DoubleMaxVector) super.sliceTemplate(origin); // specialize } @Override @@ -409,14 +402,7 @@ public DoubleMaxVector unslice(int origin, Vector w, int part, VectorMas @Override @ForceInline public DoubleMaxVector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - DoubleMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((double)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (DoubleMaxVector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java index dad2915fbf5..7db52e25e10 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/DoubleVector.java @@ -1894,14 +1894,11 @@ public final DoubleVector blend(long e, DoubleVector sliceTemplate(int origin, Vector v1) { DoubleVector that = (DoubleVector) v1; that.check(this); - double[] a0 = this.vec(); - double[] a1 = that.vec(); - double[] res = new double[a0.length]; - int vlen = res.length; - int firstPart = vlen - origin; - System.arraycopy(a0, origin, res, 0, firstPart); - System.arraycopy(a1, 0, res, firstPart, origin); - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((double)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return that.rearrange(iota).blend(this.rearrange(iota), blendMask); } /** @@ -1923,6 +1920,17 @@ DoubleVector slice(int origin, public abstract DoubleVector slice(int origin); + /*package-private*/ + final + @ForceInline + DoubleVector sliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((double)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + /** * {@inheritDoc} */ @@ -1937,21 +1945,12 @@ DoubleVector slice(int origin, unsliceTemplate(int origin, Vector w, int part) { DoubleVector that = (DoubleVector) w; that.check(this); - double[] slice = this.vec(); - double[] res = that.vec().clone(); - int vlen = res.length; - int firstPart = vlen - origin; - switch (part) { - case 0: - System.arraycopy(slice, 0, res, origin, firstPart); - break; - case 1: - System.arraycopy(slice, firstPart, res, 0, origin); - break; - default: - throw wrongPartForSlice(part); - } - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare((part == 0) ? VectorOperators.GE : VectorOperators.LT, + (broadcast((double)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return that.blend(this.rearrange(iota), blendMask); } /*package-private*/ @@ -1981,6 +1980,19 @@ DoubleVector slice(int origin, public abstract DoubleVector unslice(int origin); + /*package-private*/ + final + @ForceInline + DoubleVector + unsliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.GE, + (broadcast((double)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + private ArrayIndexOutOfBoundsException wrongPartForSlice(int part) { String msg = String.format("bad part number %d for slice operation", diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java index 61fc241e7a1..a1a9634f4e9 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -381,14 +381,7 @@ public Float128Vector slice(int origin, Vector v) { @Override @ForceInline public Float128Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Float128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((float)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Float128Vector) super.sliceTemplate(origin); // specialize } @Override @@ -409,14 +402,7 @@ public Float128Vector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public Float128Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Float128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((float)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Float128Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java index 88429843a02..69786cffc4c 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -381,14 +381,7 @@ public Float256Vector slice(int origin, Vector v) { @Override @ForceInline public Float256Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Float256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((float)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Float256Vector) super.sliceTemplate(origin); // specialize } @Override @@ -409,14 +402,7 @@ public Float256Vector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public Float256Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Float256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((float)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Float256Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java index 72c6f09a852..41b9222fffb 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -381,14 +381,7 @@ public Float512Vector slice(int origin, Vector v) { @Override @ForceInline public Float512Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Float512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((float)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Float512Vector) super.sliceTemplate(origin); // specialize } @Override @@ -409,14 +402,7 @@ public Float512Vector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public Float512Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Float512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((float)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Float512Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java index df6ea0427f4..0c615a9bc9d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -381,14 +381,7 @@ public Float64Vector slice(int origin, Vector v) { @Override @ForceInline public Float64Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Float64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((float)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Float64Vector) super.sliceTemplate(origin); // specialize } @Override @@ -409,14 +402,7 @@ public Float64Vector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Float64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((float)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Float64Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java index ef353d5e224..1a6f6c6c7ea 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -381,14 +381,7 @@ public FloatMaxVector slice(int origin, Vector v) { @Override @ForceInline public FloatMaxVector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - FloatMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((float)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (FloatMaxVector) super.sliceTemplate(origin); // specialize } @Override @@ -409,14 +402,7 @@ public FloatMaxVector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public FloatMaxVector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - FloatMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((float)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (FloatMaxVector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java index 2cad3dbea93..70b94067255 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatVector.java @@ -1906,14 +1906,11 @@ public final FloatVector blend(long e, FloatVector sliceTemplate(int origin, Vector v1) { FloatVector that = (FloatVector) v1; that.check(this); - float[] a0 = this.vec(); - float[] a1 = that.vec(); - float[] res = new float[a0.length]; - int vlen = res.length; - int firstPart = vlen - origin; - System.arraycopy(a0, origin, res, 0, firstPart); - System.arraycopy(a1, 0, res, firstPart, origin); - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((float)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return that.rearrange(iota).blend(this.rearrange(iota), blendMask); } /** @@ -1935,6 +1932,17 @@ FloatVector slice(int origin, public abstract FloatVector slice(int origin); + /*package-private*/ + final + @ForceInline + FloatVector sliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((float)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + /** * {@inheritDoc} */ @@ -1949,21 +1957,12 @@ FloatVector slice(int origin, unsliceTemplate(int origin, Vector w, int part) { FloatVector that = (FloatVector) w; that.check(this); - float[] slice = this.vec(); - float[] res = that.vec().clone(); - int vlen = res.length; - int firstPart = vlen - origin; - switch (part) { - case 0: - System.arraycopy(slice, 0, res, origin, firstPart); - break; - case 1: - System.arraycopy(slice, firstPart, res, 0, origin); - break; - default: - throw wrongPartForSlice(part); - } - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare((part == 0) ? VectorOperators.GE : VectorOperators.LT, + (broadcast((float)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return that.blend(this.rearrange(iota), blendMask); } /*package-private*/ @@ -1993,6 +1992,19 @@ FloatVector slice(int origin, public abstract FloatVector unslice(int origin); + /*package-private*/ + final + @ForceInline + FloatVector + unsliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.GE, + (broadcast((float)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + private ArrayIndexOutOfBoundsException wrongPartForSlice(int part) { String msg = String.format("bad part number %d for slice operation", diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java index 80f6f79d592..d5d39fc36d9 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Int128Vector slice(int origin, Vector v) { @Override @ForceInline public Int128Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Int128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((int)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Int128Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Int128Vector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public Int128Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Int128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((int)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Int128Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java index 6b75d52b2d1..15f2361ebcd 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Int256Vector slice(int origin, Vector v) { @Override @ForceInline public Int256Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Int256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((int)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Int256Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Int256Vector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public Int256Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Int256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((int)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Int256Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java index fa252640675..1d6551e5379 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Int512Vector slice(int origin, Vector v) { @Override @ForceInline public Int512Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Int512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((int)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Int512Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Int512Vector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public Int512Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Int512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((int)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Int512Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java index 7ce0c09f8dc..d5ef529f11d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Int64Vector slice(int origin, Vector v) { @Override @ForceInline public Int64Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Int64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((int)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Int64Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Int64Vector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Int64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((int)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Int64Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java index babdab4ccf8..bb75b346db8 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public IntMaxVector slice(int origin, Vector v) { @Override @ForceInline public IntMaxVector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - IntMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((int)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (IntMaxVector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public IntMaxVector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public IntMaxVector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - IntMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((int)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (IntMaxVector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java index 037ab4996fc..f6fa9df9d4d 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java @@ -1980,14 +1980,11 @@ public final IntVector blend(long e, IntVector sliceTemplate(int origin, Vector v1) { IntVector that = (IntVector) v1; that.check(this); - int[] a0 = this.vec(); - int[] a1 = that.vec(); - int[] res = new int[a0.length]; - int vlen = res.length; - int firstPart = vlen - origin; - System.arraycopy(a0, origin, res, 0, firstPart); - System.arraycopy(a1, 0, res, firstPart, origin); - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((int)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return that.rearrange(iota).blend(this.rearrange(iota), blendMask); } /** @@ -2009,6 +2006,17 @@ IntVector slice(int origin, public abstract IntVector slice(int origin); + /*package-private*/ + final + @ForceInline + IntVector sliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((int)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + /** * {@inheritDoc} */ @@ -2023,21 +2031,12 @@ IntVector slice(int origin, unsliceTemplate(int origin, Vector w, int part) { IntVector that = (IntVector) w; that.check(this); - int[] slice = this.vec(); - int[] res = that.vec().clone(); - int vlen = res.length; - int firstPart = vlen - origin; - switch (part) { - case 0: - System.arraycopy(slice, 0, res, origin, firstPart); - break; - case 1: - System.arraycopy(slice, firstPart, res, 0, origin); - break; - default: - throw wrongPartForSlice(part); - } - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare((part == 0) ? VectorOperators.GE : VectorOperators.LT, + (broadcast((int)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return that.blend(this.rearrange(iota), blendMask); } /*package-private*/ @@ -2067,6 +2066,19 @@ IntVector slice(int origin, public abstract IntVector unslice(int origin); + /*package-private*/ + final + @ForceInline + IntVector + unsliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.GE, + (broadcast((int)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + private ArrayIndexOutOfBoundsException wrongPartForSlice(int part) { String msg = String.format("bad part number %d for slice operation", 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 1988465cee4..a3801a317c4 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -377,14 +377,7 @@ public Long128Vector slice(int origin, Vector v) { @Override @ForceInline public Long128Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Long128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((long)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Long128Vector) super.sliceTemplate(origin); // specialize } @Override @@ -405,14 +398,7 @@ public Long128Vector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Long128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((long)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Long128Vector) super.unsliceTemplate(origin); // specialize } @Override 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 6182a0fbe2f..7f4526c0b33 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -377,14 +377,7 @@ public Long256Vector slice(int origin, Vector v) { @Override @ForceInline public Long256Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Long256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((long)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Long256Vector) super.sliceTemplate(origin); // specialize } @Override @@ -405,14 +398,7 @@ public Long256Vector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Long256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((long)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Long256Vector) super.unsliceTemplate(origin); // specialize } @Override 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 249fe7848ce..b940bd6f290 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -377,14 +377,7 @@ public Long512Vector slice(int origin, Vector v) { @Override @ForceInline public Long512Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Long512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((long)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Long512Vector) super.sliceTemplate(origin); // specialize } @Override @@ -405,14 +398,7 @@ public Long512Vector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Long512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((long)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Long512Vector) super.unsliceTemplate(origin); // specialize } @Override 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 de24768a667..b38985b7a5f 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -377,14 +377,7 @@ public Long64Vector slice(int origin, Vector v) { @Override @ForceInline public Long64Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Long64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((long)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Long64Vector) super.sliceTemplate(origin); // specialize } @Override @@ -405,14 +398,7 @@ public Long64Vector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Long64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((long)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Long64Vector) super.unsliceTemplate(origin); // specialize } @Override 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 5e61e621739..04b627e1c6a 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -377,14 +377,7 @@ public LongMaxVector slice(int origin, Vector v) { @Override @ForceInline public LongMaxVector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - LongMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((long)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (LongMaxVector) super.sliceTemplate(origin); // specialize } @Override @@ -405,14 +398,7 @@ public LongMaxVector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - LongMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((long)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (LongMaxVector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java index 76fcc0c4566..2283b3c8ec2 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java @@ -1851,14 +1851,11 @@ public final LongVector blend(long e, LongVector sliceTemplate(int origin, Vector v1) { LongVector that = (LongVector) v1; that.check(this); - long[] a0 = this.vec(); - long[] a1 = that.vec(); - long[] res = new long[a0.length]; - int vlen = res.length; - int firstPart = vlen - origin; - System.arraycopy(a0, origin, res, 0, firstPart); - System.arraycopy(a1, 0, res, firstPart, origin); - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((long)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return that.rearrange(iota).blend(this.rearrange(iota), blendMask); } /** @@ -1880,6 +1877,17 @@ LongVector slice(int origin, public abstract LongVector slice(int origin); + /*package-private*/ + final + @ForceInline + LongVector sliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((long)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + /** * {@inheritDoc} */ @@ -1894,21 +1902,12 @@ LongVector slice(int origin, unsliceTemplate(int origin, Vector w, int part) { LongVector that = (LongVector) w; that.check(this); - long[] slice = this.vec(); - long[] res = that.vec().clone(); - int vlen = res.length; - int firstPart = vlen - origin; - switch (part) { - case 0: - System.arraycopy(slice, 0, res, origin, firstPart); - break; - case 1: - System.arraycopy(slice, firstPart, res, 0, origin); - break; - default: - throw wrongPartForSlice(part); - } - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare((part == 0) ? VectorOperators.GE : VectorOperators.LT, + (broadcast((long)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return that.blend(this.rearrange(iota), blendMask); } /*package-private*/ @@ -1938,6 +1937,19 @@ LongVector slice(int origin, public abstract LongVector unslice(int origin); + /*package-private*/ + final + @ForceInline + LongVector + unsliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.GE, + (broadcast((long)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + private ArrayIndexOutOfBoundsException wrongPartForSlice(int part) { String msg = String.format("bad part number %d for slice operation", diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java index 9d9f8417598..a1c702394ad 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short128Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Short128Vector slice(int origin, Vector v) { @Override @ForceInline public Short128Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Short128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((short)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Short128Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Short128Vector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public Short128Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Short128Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((short)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Short128Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java index 74f2c24aa66..1d552f35df4 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short256Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Short256Vector slice(int origin, Vector v) { @Override @ForceInline public Short256Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Short256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((short)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Short256Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Short256Vector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public Short256Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Short256Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((short)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Short256Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java index 1b535d3d68a..ccd6b8ccf62 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short512Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Short512Vector slice(int origin, Vector v) { @Override @ForceInline public Short512Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Short512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((short)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Short512Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Short512Vector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public Short512Vector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Short512Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((short)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Short512Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java index b05149e7220..c8fa39031c6 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Short64Vector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public Short64Vector slice(int origin, Vector v) { @Override @ForceInline public Short64Vector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Short64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((short)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Short64Vector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public Short64Vector unslice(int origin, Vector w, int part, VectorMask= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - Short64Shuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((short)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (Short64Vector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java index 263b3a251df..302fa04a7bc 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortMaxVector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -387,14 +387,7 @@ public ShortMaxVector slice(int origin, Vector v) { @Override @ForceInline public ShortMaxVector slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - ShortMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast((short)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (ShortMaxVector) super.sliceTemplate(origin); // specialize } @Override @@ -415,14 +408,7 @@ public ShortMaxVector unslice(int origin, Vector w, int part, VectorMask< @Override @ForceInline public ShortMaxVector unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - ShortMaxShuffle Iota = iotaShuffle(); - VectorMask BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast((short)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return (ShortMaxVector) super.unsliceTemplate(origin); // specialize } @Override diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java index f8a5e16d046..022653cefd7 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java @@ -1981,14 +1981,11 @@ public final ShortVector blend(long e, ShortVector sliceTemplate(int origin, Vector v1) { ShortVector that = (ShortVector) v1; that.check(this); - short[] a0 = this.vec(); - short[] a1 = that.vec(); - short[] res = new short[a0.length]; - int vlen = res.length; - int firstPart = vlen - origin; - System.arraycopy(a0, origin, res, 0, firstPart); - System.arraycopy(a1, 0, res, firstPart, origin); - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((short)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return that.rearrange(iota).blend(this.rearrange(iota), blendMask); } /** @@ -2010,6 +2007,17 @@ ShortVector slice(int origin, public abstract ShortVector slice(int origin); + /*package-private*/ + final + @ForceInline + ShortVector sliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast((short)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + /** * {@inheritDoc} */ @@ -2024,21 +2032,12 @@ ShortVector slice(int origin, unsliceTemplate(int origin, Vector w, int part) { ShortVector that = (ShortVector) w; that.check(this); - short[] slice = this.vec(); - short[] res = that.vec().clone(); - int vlen = res.length; - int firstPart = vlen - origin; - switch (part) { - case 0: - System.arraycopy(slice, 0, res, origin, firstPart); - break; - case 1: - System.arraycopy(slice, firstPart, res, 0, origin); - break; - default: - throw wrongPartForSlice(part); - } - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare((part == 0) ? VectorOperators.GE : VectorOperators.LT, + (broadcast((short)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return that.blend(this.rearrange(iota), blendMask); } /*package-private*/ @@ -2068,6 +2067,19 @@ ShortVector slice(int origin, public abstract ShortVector unslice(int origin); + /*package-private*/ + final + @ForceInline + ShortVector + unsliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle iota = iotaShuffle(); + VectorMask blendMask = iota.toVector().compare(VectorOperators.GE, + (broadcast((short)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + private ArrayIndexOutOfBoundsException wrongPartForSlice(int part) { String msg = String.format("bad part number %d for slice operation", diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template index ec64f6d3ab0..26391abfb7e 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template @@ -2250,14 +2250,11 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { $abstractvectortype$ sliceTemplate(int origin, Vector<$Boxtype$> v1) { $abstractvectortype$ that = ($abstractvectortype$) v1; that.check(this); - $type$[] a0 = this.vec(); - $type$[] a1 = that.vec(); - $type$[] res = new $type$[a0.length]; - int vlen = res.length; - int firstPart = vlen - origin; - System.arraycopy(a0, origin, res, 0, firstPart); - System.arraycopy(a1, 0, res, firstPart, origin); - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle<$Boxtype$> iota = iotaShuffle(); + VectorMask<$Boxtype$> blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast(($type$)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return that.rearrange(iota).blend(this.rearrange(iota), blendMask); } /** @@ -2279,6 +2276,17 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { public abstract $abstractvectortype$ slice(int origin); + /*package-private*/ + final + @ForceInline + $abstractvectortype$ sliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle<$Boxtype$> iota = iotaShuffle(); + VectorMask<$Boxtype$> blendMask = iota.toVector().compare(VectorOperators.LT, (broadcast(($type$)(length() - origin)))); + iota = iotaShuffle(origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + /** * {@inheritDoc} */ @@ -2293,21 +2301,12 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { unsliceTemplate(int origin, Vector<$Boxtype$> w, int part) { $abstractvectortype$ that = ($abstractvectortype$) w; that.check(this); - $type$[] slice = this.vec(); - $type$[] res = that.vec().clone(); - int vlen = res.length; - int firstPart = vlen - origin; - switch (part) { - case 0: - System.arraycopy(slice, 0, res, origin, firstPart); - break; - case 1: - System.arraycopy(slice, firstPart, res, 0, origin); - break; - default: - throw wrongPartForSlice(part); - } - return vectorFactory(res); + Objects.checkIndex(origin, length() + 1); + VectorShuffle<$Boxtype$> iota = iotaShuffle(); + VectorMask<$Boxtype$> blendMask = iota.toVector().compare((part == 0) ? VectorOperators.GE : VectorOperators.LT, + (broadcast(($type$)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return that.blend(this.rearrange(iota), blendMask); } /*package-private*/ @@ -2337,6 +2336,19 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { public abstract $abstractvectortype$ unslice(int origin); + /*package-private*/ + final + @ForceInline + $abstractvectortype$ + unsliceTemplate(int origin) { + Objects.checkIndex(origin, length() + 1); + VectorShuffle<$Boxtype$> iota = iotaShuffle(); + VectorMask<$Boxtype$> blendMask = iota.toVector().compare(VectorOperators.GE, + (broadcast(($type$)(origin)))); + iota = iotaShuffle(-origin, 1, true); + return vspecies().zero().blend(this.rearrange(iota), blendMask); + } + private ArrayIndexOutOfBoundsException wrongPartForSlice(int part) { String msg = String.format("bad part number %d for slice operation", 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 011ff621d61..634960e5167 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 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -393,14 +393,7 @@ final class $vectortype$ extends $abstractvectortype$ { @Override @ForceInline public $vectortype$ slice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - $shuffletype$ Iota = iotaShuffle(); - VectorMask<$Boxtype$> BlendMask = Iota.toVector().compare(VectorOperators.LT, (broadcast(($type$)(VLENGTH-origin)))); - Iota = iotaShuffle(origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return ($vectortype$) super.sliceTemplate(origin); // specialize } @Override @@ -421,14 +414,7 @@ final class $vectortype$ extends $abstractvectortype$ { @Override @ForceInline public $vectortype$ unslice(int origin) { - if ((origin < 0) || (origin >= VLENGTH)) { - throw new ArrayIndexOutOfBoundsException("Index " + origin + " out of bounds for vector length " + VLENGTH); - } else { - $shuffletype$ Iota = iotaShuffle(); - VectorMask<$Boxtype$> BlendMask = Iota.toVector().compare(VectorOperators.GE, (broadcast(($type$)(origin)))); - Iota = iotaShuffle(-origin, 1, true); - return ZERO.blend(this.rearrange(Iota), BlendMask); - } + return ($vectortype$) super.unsliceTemplate(origin); // specialize } @Override diff --git a/test/jdk/jdk/incubator/vector/AbstractVectorConversionTest.java b/test/jdk/jdk/incubator/vector/AbstractVectorConversionTest.java index 7404cb4e6b9..1921135b9a9 100644 --- a/test/jdk/jdk/incubator/vector/AbstractVectorConversionTest.java +++ b/test/jdk/jdk/incubator/vector/AbstractVectorConversionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ public void getRunTime(ITestResult tr) { System.out.println(tr.getName() + " took " + time + " ms"); } - static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 1000); + static final int INVOC_COUNT = Integer.getInteger("jdk.incubator.vector.test.loop-iterations", 100); static IntFunction withToString(String s, IntFunction f) { return new IntFunction<>() { diff --git a/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java index 85191da8466..b93b5865ba5 100644 --- a/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector128ConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ public class Vector128ConversionTests extends AbstractVectorConversionTest { static final VectorShape SHAPE = VectorShape.S_128_BIT; + static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", 1024); @DataProvider public Object[][] fixedShapeXfixedShape() { @@ -53,25 +54,25 @@ public Object[][] fixedShapeXShape() { @Test(dataProvider = "fixedShapeXfixedShape") static void convert(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CONVERT); } @Test(dataProvider = "fixedShapeXShape") static void convertShape(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CONVERTSHAPE); } @Test(dataProvider = "fixedShapeXShape") static void castShape(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CASTSHAPE); } @Test(dataProvider = "fixedShapeXShape") static void reinterpret(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); reinterpret_kernel(src, dst, a); } } diff --git a/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java index ab73b469ae8..389ee537ecb 100644 --- a/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector256ConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ public class Vector256ConversionTests extends AbstractVectorConversionTest { static final VectorShape SHAPE = VectorShape.S_256_BIT; + static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", 1024); @DataProvider public Object[][] fixedShapeXfixedShape() { @@ -53,25 +54,25 @@ public Object[][] fixedShapeXShape() { @Test(dataProvider = "fixedShapeXfixedShape") static void convert(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CONVERT); } @Test(dataProvider = "fixedShapeXShape") static void convertShape(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CONVERTSHAPE); } @Test(dataProvider = "fixedShapeXShape") static void castShape(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CASTSHAPE); } @Test(dataProvider = "fixedShapeXShape") static void reinterpret(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); reinterpret_kernel(src, dst, a); } } diff --git a/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java index 3f802712b4c..c12481b27d4 100644 --- a/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector512ConversionTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ public class Vector512ConversionTests extends AbstractVectorConversionTest { static final VectorShape SHAPE = VectorShape.S_512_BIT; + static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", 1024); @DataProvider public Object[][] fixedShapeXfixedShape() { @@ -53,25 +54,25 @@ public Object[][] fixedShapeXShape() { @Test(dataProvider = "fixedShapeXfixedShape") static void convert(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CONVERT); } @Test(dataProvider = "fixedShapeXShape") static void convertShape(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CONVERTSHAPE); } @Test(dataProvider = "fixedShapeXShape") static void castShape(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CASTSHAPE); } @Test(dataProvider = "fixedShapeXShape") static void reinterpret(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); reinterpret_kernel(src, dst, a); } } diff --git a/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java b/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java index 835a49f025f..b98bfc0a789 100644 --- a/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java +++ b/test/jdk/jdk/incubator/vector/Vector64ConversionTests.java @@ -51,6 +51,7 @@ public class Vector64ConversionTests extends AbstractVectorConversionTest { static final VectorShape SHAPE = VectorShape.S_64_BIT; + static final int BUFFER_SIZE = Integer.getInteger("jdk.incubator.vector.test.buffer-size", 1024); @DataProvider public Object[][] fixedShapeXfixedShape() { @@ -64,25 +65,25 @@ public Object[][] fixedShapeXShape() { @Test(dataProvider = "fixedShapeXfixedShape") static void convert(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CONVERT); } @Test(dataProvider = "fixedShapeXShape") static void convertShape(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CONVERTSHAPE); } @Test(dataProvider = "fixedShapeXShape") static void castShape(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); conversion_kernel(src, dst, a, ConvAPI.CASTSHAPE); } @Test(dataProvider = "fixedShapeXShape") static void reinterpret(VectorSpecies src, VectorSpecies dst, IntFunction fa) { - Object a = fa.apply(1024); + Object a = fa.apply(BUFFER_SIZE); reinterpret_kernel(src, dst, a); } }