[PATCH] D141924: [IR] Add new intrinsics interleave and deinterleave vectors

Caroline via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 18 03:15:50 PST 2023


CarolineConcatto added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/ISDOpcodes.h:574
 
+  /// VECTOR_DEINTERLEAVE(VEC1, VEC2, IDX) - Returns a deinterleaved subvector
+  /// from VEC1 and VEC2. The vector is deinterleaved with a stride of 2
----------------
reames wrote:
> The choice here to represent the longer vector type as two vectors which are implicitly concatenated is interesting.  Can you explain why you made that choice?  Is it important for legalization?
It is more complicated when we have different sizes of input and output to legalise, keeping all inputs and outputs in the same size makes legalisation  simpler.


================
Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:11573
+                           DAG.getConstant(0, DL, MVT::i64));
+  SDValue Hi = DAG.getNode(ISD::EXTRACT_SUBVECTOR, DL, OutVT, InVec,
+                           DAG.getConstant(OutNumElts, DL, MVT::i64));
----------------
reames wrote:
> Is this actually the semantic of a extract_vector on scalable vectors?  Given e.g. 2, I'd expect to get a vector starting at the 3rd element, not split at the high half.  
I don't know if I understand what you are writing about. But just in case this is my explanation:

The ISD Node for DEINTERLEAVE, needs the input vector divided by two.  Splitting the input vector  in half  makes all operands have the same size(inputs and outputs). This makes the legalisation work less complicated.
For the deinterleave the output is always half the size of the input

```
def int_experimental_vector_deinterleave_even : DefaultAttrsIntrinsic<[LLVMHalfElementsVectorType<0>],
                                                                      [llvm_anyvector_ty],
```
So if we split the input in half they should all have the same size when using ISD Node.

As far as I understand  idx is a multiple of the known minimum vector length.
For instance:
<nxv2i64> extract_vector<nxv4i64>, the index can be only 0 or 2
<nxv4i32> extract_vector<nxv8i32>, the index can only be 0 or 4

So I believe the index is correct if we want to split the input vector in half.

 /// EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
  /// Let the result type be T, then IDX 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.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141924/new/

https://reviews.llvm.org/D141924



More information about the llvm-commits mailing list