< prev index next >

src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Int256Vector.java

Print this page

        

@@ -1105,52 +1105,67 @@
         }
         return new Float256Vector(res);
     }
 
     @Override
+    @ForceInline
     public Int256Vector rotateLanesLeft(int j) {
-        int[] vec = getElements();
-        int[] res = new int[length()];
-        for (int i = 0; i < length(); i++){
-            res[(j + i) % length()] = vec[i];
+      int L = length();
+      if (j < 0) {
+         throw new IllegalArgumentException("Index " + j + " must be zero or positive");
+      } else {
+        j = j & (L-1);
+        VectorShuffle<Integer> PermMask  = VectorShuffle.shuffleIota(SPECIES, L - j);
+        return this.rearrange(PermMask);
         }
-        return new Int256Vector(res);
     }
 
     @Override
+    @ForceInline
     public Int256Vector 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];
+      int L = length();
+      if (j < 0) {
+         throw new IllegalArgumentException("Index " + j + " must be zero or positive");
             } else {
-                res[z] = vec[i];
-            }
+        j = j & (L-1);
+        VectorShuffle<Integer> PermMask = VectorShuffle.shuffleIota(SPECIES, j);
+        return this.rearrange(PermMask);
         }
-        return new Int256Vector(res);
     }
 
     @Override
+    @ForceInline
+    @SuppressWarnings("unchecked")
     public Int256Vector shiftLanesLeft(int j) {
-        int[] vec = getElements();
-        int[] res = new int[length()];
-        for (int i = 0; i < length() - j; i++) {
-            res[i] = vec[i + j];
+       int L = length();
+       if (j < 0) {
+         throw new IllegalArgumentException("Index " + j + " must be zero or positive");
+       } else if ( j >= L ) {
+         return ZERO;
+       } else {
+         Int256Shuffle     Iota    = (Int256Shuffle)(VectorShuffle.shuffleIota(SPECIES, L-j));
+         VectorMask<Integer> BlendMask = Iota.toVector().lessThan(Int256Vector.broadcast(SPECIES, (int)(L-j)));
+         Iota    = (Int256Shuffle)(VectorShuffle.shuffleIota(SPECIES, L -j));
+         return ZERO.blend(this.rearrange(Iota),BlendMask);
         }
-        return new Int256Vector(res);
     }
 
     @Override
+    @ForceInline
+    @SuppressWarnings("unchecked")
     public Int256Vector shiftLanesRight(int j) {
-        int[] vec = getElements();
-        int[] res = new int[length()];
-        for (int i = 0; i < length() - j; i++){
-            res[i + j] = vec[i];
+       int L = length();
+       if (j < 0) {
+         throw new IllegalArgumentException("Index " + j + " must be zero or positive");
+       } else if ( j >= L ) {
+         return ZERO;
+       } else {
+         Int256Shuffle     Iota    = (Int256Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
+         VectorMask<Integer> BlendMask = Iota.toVector().greaterThanEq(Int256Vector.broadcast(SPECIES, (int)(j)));
+         Iota    = (Int256Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
+         return ZERO.blend(this.rearrange(Iota),BlendMask);
         }
-        return new Int256Vector(res);
     }
 
     @Override
     @ForceInline
     public Int256Vector rearrange(Vector<Integer> v,

@@ -1385,21 +1400,28 @@
         @Override
         public VectorSpecies<Integer> species() {
             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);
             }
             return IntVector.fromArray(SPECIES, va, 0);
         }
 
         @Override
         @ForceInline
+        public IntVector toVector() {
+            return VectorIntrinsics.shuffleToVector(Int256Vector.class, int.class, Int256Shuffle.class, this,
+                                                    SPECIES.length(), 
+                                                    (s) -> (((Int256Shuffle)(s)).toVector_helper()));
+        }
+
+        @Override
+        @ForceInline
         @SuppressWarnings("unchecked")
         public <F> VectorShuffle<F> cast(VectorSpecies<F> species) {
             if (length() != species.length())
                 throw new IllegalArgumentException("Shuffle length and species length differ");
             Class<?> stype = species.elementType();

@@ -1419,10 +1441,11 @@
             } else {
                 throw new UnsupportedOperationException("Bad lane type for casting.");
             }
         }
 
+
         @Override
         public Int256Shuffle rearrange(VectorShuffle<Integer> o) {
             Int256Shuffle s = (Int256Shuffle) o;
             byte[] r = new byte[reorder.length];
             for (int i = 0; i < reorder.length; i++) {
< prev index next >