--- old/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java 2019-05-14 07:09:27.640513846 +0530 +++ new/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Double64Vector.java 2019-05-14 07:09:27.400513840 +0530 @@ -1154,48 +1154,63 @@ @Override + @ForceInline public Double64Vector rotateLanesLeft(int j) { - double[] vec = getElements(); - double[] res = new double[length()]; - for (int i = 0; i < length(); i++){ - res[(j + i) % length()] = vec[i]; - } - return new Double64Vector(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 Double64Vector rotateLanesRight(int j) { - double[] vec = getElements(); - double[] res = new double[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 Double64Vector(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 Double64Vector shiftLanesLeft(int j) { - double[] vec = getElements(); - double[] res = new double[length()]; - for (int i = 0; i < length() - j; i++) { - res[i] = vec[i + j]; - } - return new Double64Vector(res); + int L = length(); + if (j < 0) { + throw new IllegalArgumentException("Index " + j + " must be zero or positive"); + } else if ( j >= L ) { + return ZERO; + } else { + Double64Shuffle Iota = (Double64Shuffle)(VectorShuffle.shuffleIota(SPECIES, L-j)); + VectorMask BlendMask = Iota.toVector().lessThan(Double64Vector.broadcast(SPECIES, (double)(L-j))); + Iota = (Double64Shuffle)(VectorShuffle.shuffleIota(SPECIES, L -j)); + return ZERO.blend(this.rearrange(Iota),BlendMask); + } } @Override + @ForceInline + @SuppressWarnings("unchecked") public Double64Vector shiftLanesRight(int j) { - double[] vec = getElements(); - double[] res = new double[length()]; - for (int i = 0; i < length() - j; i++){ - res[i + j] = vec[i]; - } - return new Double64Vector(res); + int L = length(); + if (j < 0) { + throw new IllegalArgumentException("Index " + j + " must be zero or positive"); + } else if ( j >= L ) { + return ZERO; + } else { + Double64Shuffle Iota = (Double64Shuffle)(VectorShuffle.shuffleIota(SPECIES, j)); + VectorMask BlendMask = Iota.toVector().greaterThanEq(Double64Vector.broadcast(SPECIES, (double)(j))); + Iota = (Double64Shuffle)(VectorShuffle.shuffleIota(SPECIES, j)); + return ZERO.blend(this.rearrange(Iota),BlendMask); + } } @Override @@ -1435,8 +1450,7 @@ return SPECIES; } - @Override - public DoubleVector toVector() { + private DoubleVector toVector_helper() { double[] va = new double[SPECIES.length()]; for (int i = 0; i < va.length; i++) { va[i] = (double) lane(i); @@ -1446,6 +1460,14 @@ @Override @ForceInline + public DoubleVector toVector() { + return VectorIntrinsics.shuffleToVector(Double64Vector.class, double.class, Double64Shuffle.class, this, + SPECIES.length(), + (s) -> (((Double64Shuffle)(s)).toVector_helper())); + } + + @Override + @ForceInline @SuppressWarnings("unchecked") public VectorShuffle cast(VectorSpecies species) { if (length() != species.length()) @@ -1469,6 +1491,7 @@ } } + @Override public Double64Shuffle rearrange(VectorShuffle o) { Double64Shuffle s = (Double64Shuffle) o;