Skip to content

Commit 4023329

Browse files
committed
[X86] collectConcatOps - add ability to recurse through insert_subvector chains
Allows us to match insert_subvector(insert_subvector(undef, insert_subvector(insert_subvector(undef, x, 0), y, 1), 0), 0), insert_subvector(insert_subvector(undef, z, 0), w, 1), 2)
1 parent bf0b21a commit 4023329

File tree

3 files changed

+707
-944
lines changed

3 files changed

+707
-944
lines changed

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3992,7 +3992,6 @@ static bool collectConcatOps(SDNode *N, SmallVectorImpl<SDValue> &Ops,
39923992
EVT VT = Src.getValueType();
39933993
EVT SubVT = Sub.getValueType();
39943994

3995-
// TODO - Handle more general insert_subvector chains.
39963995
if (VT.getSizeInBits() == (SubVT.getSizeInBits() * 2)) {
39973996
// insert_subvector(undef, x, lo)
39983997
if (Idx == 0 && Src.isUndef()) {
@@ -4005,8 +4004,19 @@ static bool collectConcatOps(SDNode *N, SmallVectorImpl<SDValue> &Ops,
40054004
if (Src.getOpcode() == ISD::INSERT_SUBVECTOR &&
40064005
Src.getOperand(1).getValueType() == SubVT &&
40074006
isNullConstant(Src.getOperand(2))) {
4008-
Ops.push_back(Src.getOperand(1));
4009-
Ops.push_back(Sub);
4007+
// Attempt to recurse into inner (matching) concats.
4008+
SDValue Lo = Src.getOperand(1);
4009+
SDValue Hi = Sub;
4010+
SmallVector<SDValue, 2> LoOps, HiOps;
4011+
if (collectConcatOps(Lo.getNode(), LoOps, DAG) &&
4012+
collectConcatOps(Hi.getNode(), HiOps, DAG) &&
4013+
LoOps.size() == HiOps.size()) {
4014+
Ops.append(LoOps);
4015+
Ops.append(HiOps);
4016+
return true;
4017+
}
4018+
Ops.push_back(Lo);
4019+
Ops.push_back(Hi);
40104020
return true;
40114021
}
40124022
// insert_subvector(x, extract_subvector(x, lo), hi)

0 commit comments

Comments
 (0)