< prev index next >

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

Print this page
rev 49509 : [vector] Intrinsic support for resize

@@ -671,13 +671,13 @@
     public <F> Vector<F, Shapes.S64Bit> rebracket(Species<F, Shapes.S64Bit> species) {
         Objects.requireNonNull(species);
         // TODO: check proper element type
         // TODO: update to pass the two species as an arguments and ideally
         // push down intrinsic call into species implementation
-        return VectorIntrinsics.rebracket(
+        return VectorIntrinsics.reinterpret(
             Short64Vector.class, short.class, LENGTH,
-            species.elementType(), this,
+            species.elementType(), species.length(), this,
             (v, t) -> species.reshape(v)
         );
     }
 
     // Accessors

@@ -762,13 +762,13 @@
         @ForceInline
         @SuppressWarnings("unchecked")
         public <Z> Mask<Z, Shapes.S64Bit> rebracket(Species<Z, Shapes.S64Bit> species) {
             Objects.requireNonNull(species);
             // TODO: check proper element type
-            return VectorIntrinsics.rebracket(
+            return VectorIntrinsics.reinterpret(
                 Short64Mask.class, short.class, LENGTH,
-                species.elementType(), this,
+                species.elementType(), species.length(), this,
                 (m, t) -> m.reshape(species)
             );
         }
 
         // Unary operations

@@ -861,30 +861,35 @@
            sb.append("]");
            return sb.toString();
         }
 
         @Override
+        @ForceInline
         public int bitSize() {
             return BIT_SIZE;
         }
 
         @Override
+        @ForceInline
         public int length() {
             return LENGTH;
         }
 
         @Override
+        @ForceInline
         public Class<Short> elementType() {
             return Short.class;
         }
 
         @Override
+        @ForceInline
         public int elementSize() {
             return Short.SIZE;
         }
 
         @Override
+        @ForceInline
         public Shapes.S64Bit shape() {
             return Shapes.S_64_BIT;
         }
 
         @Override

@@ -976,7 +981,45 @@
         @Override
         @ForceInline
         public Short64Vector fromArray(short[] a, int ax, Mask<Short, Shapes.S64Bit> m) {
             return zero().blend(fromArray(a, ax), m); // TODO: use better default impl: op(m, i -> a[ax + i]);
         }
+
+        @Override
+        @ForceInline
+        @SuppressWarnings("unchecked")
+        public <T extends Shape> Short64Vector resize(Vector<Short, T> o) {
+            Objects.requireNonNull(o);
+            if (o.bitSize() == 64) {
+                Short64Vector so = (Short64Vector)o;
+                return VectorIntrinsics.reinterpret(
+                    Short64Vector.class, short.class, so.length(),
+                    Short.class, LENGTH, so,
+                    (v, t) -> (Short64Vector)reshape(v)
+                );
+            } else if (o.bitSize() == 128) {
+                Short128Vector so = (Short128Vector)o;
+                return VectorIntrinsics.reinterpret(
+                    Short128Vector.class, short.class, so.length(),
+                    Short.class, LENGTH, so,
+                    (v, t) -> (Short64Vector)reshape(v)
+                );
+            } else if (o.bitSize() == 256) {
+                Short256Vector so = (Short256Vector)o;
+                return VectorIntrinsics.reinterpret(
+                    Short256Vector.class, short.class, so.length(),
+                    Short.class, LENGTH, so,
+                    (v, t) -> (Short64Vector)reshape(v)
+                );
+            } else if (o.bitSize() == 512) {
+                Short512Vector so = (Short512Vector)o;
+                return VectorIntrinsics.reinterpret(
+                    Short512Vector.class, short.class, so.length(),
+                    Short.class, LENGTH, so,
+                    (v, t) -> (Short64Vector)reshape(v)
+                );
+            } else {
+                throw new InternalError("Unimplemented size");
+            }
+        }
     }
 }
< prev index next >