[llvm] Port `NVPTXTargetLowering::LowerCONCAT_VECTORS` to SelectionDAG (PR #120030)

Ethan Kaji via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 23:15:52 PST 2024


================
@@ -1517,18 +1518,36 @@ SDValue SelectionDAGLegalize::ExpandInsertToVectorThroughStack(SDValue Op) {
                      BaseVecAlignment);
 }
 
+SDValue SelectionDAGLegalize::ExpandConcatVectors(SDNode *Node) {
+  assert(Node->getOpcode() == ISD::CONCAT_VECTORS && "Unexpected opcode!");
+  SDLoc DL(Node);
+  SmallVector<SDValue, 16> Ops;
+  unsigned NumOperands = Node->getNumOperands();
+  MVT VectorIdxType = TLI.getVectorIdxTy(DAG.getDataLayout());
+  for (unsigned I = 0; I < NumOperands; ++I) {
+    SDValue SubOp = Node->getOperand(I);
+    EVT VectorValueType = SubOp.getValueType();
+    EVT ElementValueType = TLI.getTypeToTransformTo(
+        *DAG.getContext(), VectorValueType.getVectorElementType());
----------------
Esan5 wrote:

Not really sure if this would be sufficient, but I think something like this might work.

```suggestion
    EVT ElementValueType = TLI.getTypeToTransformTo(
        *DAG.getContext(), VectorValueType.getVectorElementType());
    if (ElementValueType != VectorValueType.getVectorElementType()) {
      return ExpandVectorBuildThroughStack(Node);
    }
```

https://github.com/llvm/llvm-project/pull/120030


More information about the llvm-commits mailing list