< prev index next >

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

Print this page

        

@@ -1092,52 +1092,67 @@
         }
         return new Double64Vector(res);
     }
 
     @Override
+    @ForceInline
     public Long64Vector 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 Long64Vector(res);
     }
 
     @Override
+    @ForceInline
     public Long64Vector 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 Long64Vector(res);
     }
 
     @Override
+    @ForceInline
+    @SuppressWarnings("unchecked")
     public Long64Vector 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 {
+         Long64Shuffle     Iota    = (Long64Shuffle)(VectorShuffle.shuffleIota(SPECIES, L-j));
+         VectorMask<Long> BlendMask = Iota.toVector().lessThan(Long64Vector.broadcast(SPECIES, (long)(L-j)));
+         Iota    = (Long64Shuffle)(VectorShuffle.shuffleIota(SPECIES, L -j));
+         return ZERO.blend(this.rearrange(Iota),BlendMask);
         }
-        return new Long64Vector(res);
     }
 
     @Override
+    @ForceInline
+    @SuppressWarnings("unchecked")
     public Long64Vector 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 {
+         Long64Shuffle     Iota    = (Long64Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
+         VectorMask<Long> BlendMask = Iota.toVector().greaterThanEq(Long64Vector.broadcast(SPECIES, (long)(j)));
+         Iota    = (Long64Shuffle)(VectorShuffle.shuffleIota(SPECIES, j));
+         return ZERO.blend(this.rearrange(Iota),BlendMask);
         }
-        return new Long64Vector(res);
     }
 
     @Override
     @ForceInline
     public Long64Vector rearrange(Vector<Long> v,

@@ -1372,21 +1387,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(Long64Vector.class, long.class, Long64Shuffle.class, this,
+                                                    SPECIES.length(), 
+                                                    (s) -> (((Long64Shuffle)(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();

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