-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AIE2P] Combine G_SHUFFLE_VECTOR into Extract+Broadcast #284
base: aie-public
Are you sure you want to change the base?
Conversation
@@ -1768,3 +1773,44 @@ bool llvm::matchShuffleToBroadcast(MachineInstr &MI, MachineRegisterInfo &MRI, | |||
MatchInfo = std::make_pair(DstReg, Src1Reg); | |||
return true; | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: include some gMIR example that shows the pattern to be matched.
|
||
const Register Src1VecReg = MI.getOperand(1).getReg(); | ||
const LLT ElemTy = MRI.getType(Src1VecReg).getElementType(); | ||
if (ElemTy.getSizeInBits() == 64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a reason to block this size here? For example, we are legalizing bigger types here: #283
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, I removed it.
(defs root:$root, build_fn_matchinfo:$matchinfo), | ||
(match (wip_match_opcode G_SHUFFLE_VECTOR): $root, | ||
[{ return matchShuffleToExtractBroadcast(*${root}, MRI, (const AIEBaseInstrInfo &)B.getTII(), ${matchinfo}); }]), | ||
(apply [{ Helper.applyBuildFn(*${root}, ${matchinfo}); }])>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice implementation using std::function
.
; CHECK-NEXT: PseudoRET implicit $lr, implicit [[AIE_UNPAD_VECTOR]](<8 x s32>) | ||
%0:_(<8 x s32>) = COPY $wl0 | ||
%1:_(<8 x s32>) = COPY $wl1 | ||
%2:_(<8 x s32>) = G_SHUFFLE_VECTOR %0(<8 x s32>), %1(<8 x s32>), shufflemask(2, 2, 2, 2, 2, 2, 2, 2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you also include a negative test case?
15def52
to
296dd59
Compare
for (unsigned I = 0; I < NumElems; I++) { | ||
int Idx = Mask[I]; | ||
if (Idx < 0) | ||
continue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is that legal to have a negative index?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, it means that the value is undef
.
return false; | ||
} | ||
} | ||
assert(UniqOpIdx >= 0 && "Couldn't find a unique operand to extract!"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: To make this function more concise, I'd suggest creating a helper like: std::optional<int> getUniqueIndex(ArrayRef<int> Mask);
.
296dd59
to
1fb23a9
Compare
No description provided.