< prev index next >

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

Print this page

        

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

@@ -1446,21 +1461,28 @@
         @Override
         public VectorSpecies<Float> species() {
             return SPECIES;
         }
 
-        @Override
-        public FloatVector toVector() {
+        private FloatVector toVector_helper() {
             float[] va = new float[SPECIES.length()];
             for (int i = 0; i < va.length; i++) {
               va[i] = (float) lane(i);
             }
             return FloatVector.fromArray(SPECIES, va, 0);
         }
 
         @Override
         @ForceInline
+        public FloatVector toVector() {
+            return VectorIntrinsics.shuffleToVector(Float512Vector.class, float.class, Float512Shuffle.class, this,
+                                                    SPECIES.length(), 
+                                                    (s) -> (((Float512Shuffle)(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();

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