< prev index next >

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

Print this page
@@ -1,7 +1,7 @@
  /*
-  * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved.
+  * Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   *
   * This code is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License version 2 only, as
   * published by the Free Software Foundation.  Oracle designates this

@@ -1037,10 +1037,16 @@
   * {@code VectorShuffle} object, which acts as an routing table
   * mapping source lanes to destination lanes.  A {@code VectorShuffle}
   * can encode a mathematical permutation as well as many other
   * patterns of data movement.
   *
+  * <li>The {@link #compress(VectorMask)} and {@link #expand(VectorMask)}
+  * methods, which select up to {@code VLENGTH} lanes from an
+  * input vector, and assemble them in lane order.  The selection of lanes
+  * is controlled by a {@code VectorMask}, with set lane elements mapping, by
+  * compression or expansion in lane order, source lanes to destination lanes.
+  *
   * </ul>
   * <p> Some vector operations are not lane-wise, but rather move data
   * across lane boundaries.  Such operations are typically rare in SIMD
   * code, though they are sometimes necessary for specific algorithms
   * that manipulate data formats at a low level, and/or require SIMD

@@ -2687,10 +2693,48 @@
       * @see VectorShuffle#laneIsValid()
       * @see #slice(int,Vector)
       */
      public abstract Vector<E> rearrange(VectorShuffle<E> s, Vector<E> v);
  
+     /**
+      * Compresses the lane elements of this vector selecting lanes
+      * under the control of a specific mask.
+      *
+      * This is a cross-lane operation that compresses the lane
+      * elements of this vector as selected by the specified mask.
+      *
+      * For each lane {@code N} of the mask, if the mask at
+      * lane {@code N} is set, the element at lane {@code N}
+      * of input vector is selected and stored into the output
+      * vector contiguously starting from the lane {@code 0}.
+      * All the upper remaining lanes, if any, of the output
+      * vector are set to zero.
+      *
+      * @param m the mask controlling the compression
+      * @return the compressed lane elements of this vector
+      */
+     public abstract Vector<E> compress(VectorMask<E> m);
+ 
+     /**
+      * Expands the lane elements of this vector
+      * under the control of a specific mask.
+      *
+      * This is a cross-lane operation that expands the contiguous lane
+      * elements of this vector into lanes of an output vector
+      * as selected by the specified mask.
+      *
+      * For each lane {@code N} of the mask, if the mask at
+      * lane {@code N} is set, the next contiguous element of input vector
+      * starting from lane {@code 0} is selected and stored into the output
+      * vector at lane {@code N}.
+      * All the remaining lanes, if any, of the output vector are set to zero.
+      *
+      * @param m the mask controlling the compression
+      * @return the expanded lane elements of this vector
+      */
+     public abstract Vector<E> expand(VectorMask<E> m);
+ 
      /**
       * Using index values stored in the lanes of this vector,
       * assemble values stored in second vector {@code v}.
       * The second vector thus serves as a table, whose
       * elements are selected by indexes in the current vector.
< prev index next >