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