-
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] Legalize G_UNMERGE_VALUES 256-bit vector to 2 128-bit vectors #282
base: aie-public
Are you sure you want to change the base?
Conversation
7b93774
to
7ef0b48
Compare
7ef0b48
to
8df98bb
Compare
@@ -551,8 +551,10 @@ AIE2PLegalizerInfo::AIE2PLegalizerInfo(const AIE2PSubtarget &ST) | |||
const LLT &DstTy = Query.Types[0]; | |||
const LLT &SrcTy = Query.Types[1]; | |||
|
|||
return SrcTy.isVector() && DstTy.isScalar() && | |||
DstTy == SrcTy.getElementType(); | |||
return (DstTy.isVector() && SrcTy.getSizeInBits() == 256 && |
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 add a comment to explain which cases this handles? (for both the existing and new case)
8df98bb
to
a2d74e1
Compare
@@ -231,6 +231,57 @@ bool AIELegalizerHelper::legalizeG_BUILD_VECTOR(LegalizerHelper &Helper, | |||
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.
Can we have a description of the input->output of this custom legalization rule?
|
||
// Concatenate the src1 and src2 vectors, shift right | ||
// and extract the resulting lower 512-bit vector | ||
def G_AIE_VSHIFT : AIEGenericInstruction { |
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.
I was expecting "right" to be visible in the opcode itself. If I see this opcode there is no way to discover that it does right shift without looking to the comment.
const AIEBaseInstrInfo *II = ST.getInstrInfo(); | ||
const unsigned UnpadOpc = II->getGenericUnpadVectorOpcode(); | ||
const Register SrcReg = MI.getOperand(MI.getNumOperands() - 1).getReg(); | ||
const Register Dst1Reg = MI.getOperand(0).getReg(); |
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: maybe DstRegLow
and DstRegHigh
to improve readability.
MIRBuilder.buildInstr(TargetOpcode::G_IMPLICIT_DEF, {SrcTy}, {}) | ||
.getReg(0); | ||
|
||
const LLT Vec512 = |
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: const LLT Vec512 = SrcTy.multiplyElements(2);
|
||
// VSHIFT operates on 512-bit inputs. We need to pad the 256-bit source | ||
// operand to 512-bit | ||
const Register ImplicitDef256 = |
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: const Register ImplicitDef256 = MIRBuilder.buildUndef(SrcTy).getReg(0);
MIRBuilder.buildConcatVectors({Vec512}, {SrcReg, ImplicitDef256}); | ||
|
||
// The second input will be ignored. Just create a dummy input | ||
auto ImplicitDef512 = |
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: auto ImplicitDef512 = MIRBuilder.buildUndef(Vec512);
This PR introduces
G_AIE_VSHIFT
gMIR opcode which is selected tovshift
instruction. And this is utilized to legalize G_UNMERGE_VALUES 256-bit vector to 2 128-bit vector.