[PATCH] D79806: [CodeGen][SVE] Specify meaning of EXTRACT_SUBVECTOR for scalable vectors

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 12 14:00:37 PDT 2020


sdesmalen created this revision.
sdesmalen added reviewers: efriedma, ctetreau, rogfer01.
Herald added subscribers: psnobl, rkruppe, tschuett.
Herald added a project: LLVM.

This patch contains only changes to the description of
EXTRACT_SUBVECTOR (and similarly to INSERT_SUBVECTOR) for scalable
vectors, and specifies that the IDX is scaled by the same runtime
scaling as the extracted (or inserted) vector.

This patch is not NFC because it sets the meaning of these nodes for 
scalable vectors, which future patches will build upon.

This definition is the most natural extension to EXTRACT_SUBVECTOR
for scalable vectors, as most use-cases that work on fixed-width types
will have the same meaning for scalable types. For legalization for example,
it is common to split the vector operation to operate on the LO and HI
halfs of a vector.

For a fixed width vector <16 x i8> this would be expressed with:

  v16i8 %res = EXTRACT_SUBVECTOR v32i8 %v, i32 16

For a scalable vector, this would similarly be expressed as:

  nxv16i8 %res = EXTRACT_SUBVECTOR nxv32i8 %V, i32 16

By giving this meaning to IDX for scalable vectors, most existing
optimisations on EXTRACT_SUBVECTOR (and similarly INSERT_SUBVECTOR)
work for scalable vectors without any changes.

This definition also allows extracting a fixed-width subvector from
a scalable vector, which is useful to e.g. extract the low N lanes
of a scalable vector.


https://reviews.llvm.org/D79806

Files:
  llvm/include/llvm/CodeGen/ISDOpcodes.h


Index: llvm/include/llvm/CodeGen/ISDOpcodes.h
===================================================================
--- llvm/include/llvm/CodeGen/ISDOpcodes.h
+++ llvm/include/llvm/CodeGen/ISDOpcodes.h
@@ -408,17 +408,20 @@
     /// lengths of the input vectors.
     CONCAT_VECTORS,
 
-    /// INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector
-    /// with VECTOR2 inserted into VECTOR1 at the (potentially
-    /// variable) element number IDX, which must be a multiple of the
-    /// VECTOR2 vector length.  The elements of VECTOR1 starting at
-    /// IDX are overwritten with VECTOR2.  Elements IDX through
-    /// vector_length(VECTOR2) must be valid VECTOR1 indices.
+    /// INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2
+    /// inserted into VECTOR1. Let the type of VECTOR2 be T, then IDX is first
+    /// scaled by the same runtime scaling factor of T to form IDX_0, which
+    /// represents the starting element number at which VECTOR2 will be
+    /// inserted. The elements of VECTOR1 starting at IDX_0 are overwritten with
+    /// VECTOR2. Elements IDX_0 through (IDX_0 + vector_length(VECTOR2) - 1)
+    /// must be valid VECTOR1 indices.
     INSERT_SUBVECTOR,
 
-    /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR (an
-    /// vector value) starting with the element number IDX, which must be a
-    /// constant multiple of the result vector length.
+    /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
+    /// Let the result type be T, then IDX is first scaled by the same runtime
+    /// scaling factor of T. The resulting index represents the starting
+    /// element number from which a subvector of type T is extracted.
+    /// IDX must be a constant multiple of T's known minimum vector length.
     EXTRACT_SUBVECTOR,
 
     /// VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79806.263510.patch
Type: text/x-patch
Size: 1910 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200512/540b29eb/attachment.bin>


More information about the llvm-commits mailing list