Skip to content

Commit d428827

Browse files
[AIE2] Implement legalization for G_SHUFFLE_VECTOR
This implements the simple legalization that lowers G_SHUFFLE_VECTOR into extracts of the elements based on the mask and then combining them using a G_BUILD_VECTOR. Our architecture has a VSHUFFLE instruction which could be used to implement some patterns more efficiently.
1 parent 9bfe5f8 commit d428827

File tree

2 files changed

+1025
-0
lines changed

2 files changed

+1025
-0
lines changed

llvm/lib/Target/AIE/AIELegalizerInfo.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,24 @@ AIELegalizerInfo::AIELegalizerInfo(const AIEBaseSubtarget &ST) {
493493
.clampMaxNumElements(0, S16, 32)
494494
.clampMaxNumElements(0, S32, 16)
495495
.custom();
496+
497+
getActionDefinitionsBuilder(G_SHUFFLE_VECTOR)
498+
.unsupportedIf(IsNotValidDestinationVector)
499+
.lowerIf([=](const LegalityQuery &Query) {
500+
const LLT DstTy = Query.Types[0];
501+
const LLT SrcTy = Query.Types[1];
502+
503+
return DstTy.isVector() && SrcTy.isScalar() &&
504+
(2 * SrcTy.getSizeInBits()) == DstTy.getSizeInBits();
505+
})
506+
.clampMinNumElements(0, S8, 32)
507+
.clampMinNumElements(0, S16, 16)
508+
.clampMinNumElements(0, S32, 8)
509+
// Shuffle acts a concat
510+
.lowerIf(isValidVectorMergeUnmergeOp(0, 1))
511+
.lowerIf([=](const LegalityQuery &Query) {
512+
return Query.Types[0] == Query.Types[1];
513+
});
496514
}
497515

498516
getActionDefinitionsBuilder(G_JUMP_TABLE).custom();

0 commit comments

Comments
 (0)