< prev index next >

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

Print this page

        

@@ -1105,52 +1105,67 @@
         }
         return new Double512Vector(res);
     }
 
     @Override
+    @ForceInline
     public Long512Vector rotateLanesLeft(int j) {
-        long[] vec = getElements();
-        long[] res = new long[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<Long> PermMask  = VectorShuffle.shuffleIota(SPECIES, L - j);
+        return this.rearrange(PermMask);
         }
-        return new Long512Vector(res);
     }
 
     @Override
+    @ForceInline
     public Long512Vector rotateLanesRight(int j) {
-        long[] vec = getElements();
-        long[] res = new long[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<Long> PermMask = VectorShuffle.shuffleIota(SPECIES, j);
+        return this.rearrange(PermMask);
         }
-        return new Long512Vector(res);
     }
 
     @Override
+    @ForceInline
+    @SuppressWarnings("unchecked")
     public Long512Vector shiftLanesLeft(int j) {
-        long[] vec = getElements();
-        long[] res = new long[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 {
+         Long512Shuffle     Iota    = (Long512Shuffle)(VectorShuffle.shuffleIota(SPECIES, L-j));
+         VectorMask<Long> BlendMask = Iota.toVector().lessThan(Long512Vector.broadcast(SPECIES, (long)(L-j)));
+         Iota    = (Long512Shuffle)(VectorShuffle.shuffleIota(SPECIES, L -j));
+         return ZERO.blend(this.rearrange(Iota),BlendMask);
         }
-        return new Long512Vector(res);
     }
 
     @Override
+    @ForceInline
+    @SuppressWarnings("unchecked")
     public Long512Vector shiftLanesRight(int j) {
-        long[] vec = getElements();
-        long[] res = new long[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 {
+         Long512Shuffle     Iota    = (Long512Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
+         VectorMask<Long> BlendMask = Iota.toVector().greaterThanEq(Long512Vector.broadcast(SPECIES, (long)(j)));
+         Iota    = (Long512Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
+         return ZERO.blend(this.rearrange(Iota),BlendMask);
         }
-        return new Long512Vector(res);
     }
 
     @Override
     @ForceInline
     public Long512Vector rearrange(Vector<Long> v,

@@ -1385,21 +1400,28 @@
         @Override
         public VectorSpecies<Long> species() {
             return SPECIES;
         }
 
-        @Override
-        public LongVector toVector() {
+        private LongVector toVector_helper() {
             long[] va = new long[SPECIES.length()];
             for (int i = 0; i < va.length; i++) {
               va[i] = (long) lane(i);
             }
             return LongVector.fromArray(SPECIES, va, 0);
         }
 
         @Override
         @ForceInline
+        public LongVector toVector() {
+            return VectorIntrinsics.shuffleToVector(Long512Vector.class, long.class, Long512Shuffle.class, this,
+                                                    SPECIES.length(), 
+                                                    (s) -> (((Long512Shuffle)(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 Long512Shuffle rearrange(VectorShuffle<Long> o) {
             Long512Shuffle s = (Long512Shuffle) o;
             byte[] r = new byte[reorder.length];
             for (int i = 0; i < reorder.length; i++) {
< prev index next >