--- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java 2019-05-14 07:09:30.896513923 +0530 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/FloatMaxVector.java 2019-05-14 07:09:30.660513918 +0530 @@ -1167,48 +1167,63 @@ @Override + @ForceInline public FloatMaxVector rotateLanesLeft(int j) { - float[] vec = getElements(); - float[] res = new float[length()]; - for (int i = 0; i < length(); i++){ - res[(j + i) % length()] = vec[i]; - } - return new FloatMaxVector(res); + int L = length(); + if (j < 0) { + throw new IllegalArgumentException("Index " + j + " must be zero or positive"); + } else { + j = j & (L-1); + VectorShuffle PermMask = VectorShuffle.shuffleIota(SPECIES, L - j); + return this.rearrange(PermMask); + } } @Override + @ForceInline public FloatMaxVector rotateLanesRight(int j) { - float[] vec = getElements(); - float[] res = new float[length()]; - for (int i = 0; i < length(); i++){ - int z = i - j; - if(j < 0) { - res[length() + z] = vec[i]; - } else { - res[z] = vec[i]; - } - } - return new FloatMaxVector(res); + int L = length(); + if (j < 0) { + throw new IllegalArgumentException("Index " + j + " must be zero or positive"); + } else { + j = j & (L-1); + VectorShuffle PermMask = VectorShuffle.shuffleIota(SPECIES, j); + return this.rearrange(PermMask); + } } @Override + @ForceInline + @SuppressWarnings("unchecked") public FloatMaxVector shiftLanesLeft(int j) { - float[] vec = getElements(); - float[] res = new float[length()]; - for (int i = 0; i < length() - j; i++) { - res[i] = vec[i + j]; - } - return new FloatMaxVector(res); + int L = length(); + if (j < 0) { + throw new IllegalArgumentException("Index " + j + " must be zero or positive"); + } else if ( j >= L ) { + return ZERO; + } else { + FloatMaxShuffle Iota = (FloatMaxShuffle)(VectorShuffle.shuffleIota(SPECIES, L-j)); + VectorMask BlendMask = Iota.toVector().lessThan(FloatMaxVector.broadcast(SPECIES, (float)(L-j))); + Iota = (FloatMaxShuffle)(VectorShuffle.shuffleIota(SPECIES, L -j)); + return ZERO.blend(this.rearrange(Iota),BlendMask); + } } @Override + @ForceInline + @SuppressWarnings("unchecked") public FloatMaxVector shiftLanesRight(int j) { - float[] vec = getElements(); - float[] res = new float[length()]; - for (int i = 0; i < length() - j; i++){ - res[i + j] = vec[i]; - } - return new FloatMaxVector(res); + int L = length(); + if (j < 0) { + throw new IllegalArgumentException("Index " + j + " must be zero or positive"); + } else if ( j >= L ) { + return ZERO; + } else { + FloatMaxShuffle Iota = (FloatMaxShuffle)(VectorShuffle.shuffleIota(SPECIES, j)); + VectorMask BlendMask = Iota.toVector().greaterThanEq(FloatMaxVector.broadcast(SPECIES, (float)(j))); + Iota = (FloatMaxShuffle)(VectorShuffle.shuffleIota(SPECIES, j)); + return ZERO.blend(this.rearrange(Iota),BlendMask); + } } @Override @@ -1448,8 +1463,7 @@ return SPECIES; } - @Override - public FloatVector toVector() { + private FloatVector toVector_helper() { float[] va = new float[SPECIES.length()]; for (int i = 0; i < va.length; i++) { va[i] = (float) lane(i); @@ -1459,6 +1473,14 @@ @Override @ForceInline + public FloatVector toVector() { + return VectorIntrinsics.shuffleToVector(FloatMaxVector.class, float.class, FloatMaxShuffle.class, this, + SPECIES.length(), + (s) -> (((FloatMaxShuffle)(s)).toVector_helper())); + } + + @Override + @ForceInline @SuppressWarnings("unchecked") public VectorShuffle cast(VectorSpecies species) { if (length() != species.length()) @@ -1482,6 +1504,7 @@ } } + @Override public FloatMaxShuffle rearrange(VectorShuffle o) { FloatMaxShuffle s = (FloatMaxShuffle) o;