[llvm] c6c5aad - [X86] truncateVectorWithPACK - avoid concat_vectors(extract_subvector(pack()),extract_subvector(pack())) for sub-128 bit vectors
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 21 11:12:42 PDT 2023
Author: Simon Pilgrim
Date: 2023-07-21T19:10:17+01:00
New Revision: c6c5aad6a24311e855b6ab7054b861a0a066e08c
URL: https://github.com/llvm/llvm-project/commit/c6c5aad6a24311e855b6ab7054b861a0a066e08c
DIFF: https://github.com/llvm/llvm-project/commit/c6c5aad6a24311e855b6ab7054b861a0a066e08c.diff
LOG: [X86] truncateVectorWithPACK - avoid concat_vectors(extract_subvector(pack()),extract_subvector(pack())) for sub-128 bit vectors
As we start using this after type legalization, we must avoid creating concat_vectors nodes so late.
Added:
Modified:
llvm/lib/Target/X86/X86ISelLowering.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index 7c322faa6a208d..8ff3d86b81317e 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -22890,11 +22890,19 @@ static SDValue truncateVectorWithPACK(unsigned Opcode, EVT DstVT, SDValue In,
// Recursively pack lower/upper subvectors, concat result and pack again.
assert(SrcSizeInBits >= 256 && "Expected 256-bit vector or greater");
- EVT PackedVT = EVT::getVectorVT(Ctx, PackedSVT, NumElems / 2);
- Lo = truncateVectorWithPACK(Opcode, PackedVT, Lo, DL, DAG, Subtarget);
- Hi = truncateVectorWithPACK(Opcode, PackedVT, Hi, DL, DAG, Subtarget);
- PackedVT = EVT::getVectorVT(Ctx, PackedSVT, NumElems);
+ EVT PackedVT = EVT::getVectorVT(Ctx, PackedSVT, NumElems);
+ if (PackedVT.is128BitVector()) {
+ // Avoid CONCAT_VECTORS on sub-128bit nodes as these can fail after
+ // type legalization.
+ SDValue Res =
+ truncateVectorWithPACK(Opcode, PackedVT, In, DL, DAG, Subtarget);
+ return truncateVectorWithPACK(Opcode, DstVT, Res, DL, DAG, Subtarget);
+ }
+
+ EVT HalfPackedVT = EVT::getVectorVT(Ctx, PackedSVT, NumElems / 2);
+ Lo = truncateVectorWithPACK(Opcode, HalfPackedVT, Lo, DL, DAG, Subtarget);
+ Hi = truncateVectorWithPACK(Opcode, HalfPackedVT, Hi, DL, DAG, Subtarget);
SDValue Res = DAG.getNode(ISD::CONCAT_VECTORS, DL, PackedVT, Lo, Hi);
return truncateVectorWithPACK(Opcode, DstVT, Res, DL, DAG, Subtarget);
}
More information about the llvm-commits
mailing list