-
Notifications
You must be signed in to change notification settings - Fork 14
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
Support for allowing direct VEXTRACT to 20-bit registers #233
base: aie-public
Are you sure you want to change the base?
Conversation
llvm/test/CodeGen/AIE/aie2/GlobalISel/prelegalizercombiner-s20-narrowing.mir
Outdated
Show resolved
Hide resolved
llvm/test/CodeGen/AIE/aie2/GlobalISel/prelegalizercombiner-s20-narrowing.mir
Outdated
Show resolved
Hide resolved
Given that you mentioned there are no QoR gain, I would recommend you to re look at the instruction that consume S20 type reg. |
650d8a9
to
d5d7cf0
Compare
d5d7cf0
to
f12f1a4
Compare
11cd993
to
35027af
Compare
MIRBuilder.buildAssertInstr(AssertExtOpcode, ExtReg20Bit, DstReg20Bit, | ||
SrcEltSize); | ||
MIRBuilder.buildInstr(ExtOpcode, {DstReg}, {ExtReg20Bit}); | ||
MI.eraseFromParent(); |
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.
Now we are safe ;-)
35027af
to
000b09e
Compare
000b09e
to
e7731e6
Compare
@@ -192,7 +190,6 @@ define void @above_threshold(i32 signext %in, ptr %out) nounwind { | |||
; RV64I-PIC-LABEL: above_threshold: | |||
; RV64I-PIC: # %bb.0: # %entry | |||
; RV64I-PIC-NEXT: li a2, 5 | |||
; RV64I-PIC-NEXT: sext.w a0, a0 |
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! Did you check all targets?
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, I have checked all targets.
/// To : %9:_(s20) = G_AIE_SEXT_EXTRACT_VECTOR_ELT %2(<32 x s16>), %0(s32) | ||
/// %10:_(s20) = G_ASSERT_[S/Z]EXT %9, 16 | ||
/// %4:_(s16) = G_TRUNC %10(s20) | ||
/// %5:_(s20) = G_[S/Z]EXT %4(s16) |
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 need to change the return types? I would expect that we only need to add a %10:_(s32) = G_ASSERT_[S/Z]EXT %9, 16
and keep the rest intact thanks to the new sext(trunc x)
combiner you added previously.
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, we need to change the return types, because the pattern that is written in new sext(trunc x)
combiner will not match in this case as m_SpecificType is trying to match s20 but return type here is s32.
mi_match(SrcReg, MRI, m_GTrunc(m_all_of(m_Reg(Reg), m_SpecificType(DstTy))))
e7731e6
to
467672d
Compare
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.
LGTM.
2d5aaad
to
de8468e
Compare
de8468e
to
c3cba3e
Compare
%var:_(s32) = COPY $vgpr0 | ||
%assert:_(s32) = G_ASSERT_SEXT %var, 16 | ||
%trunc:_(s16) = G_TRUNC %assert(s32) | ||
%sext:_(s64) = G_SEXT %trunc(s16) |
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: I guess we could still eliminate the G_TRUNC
, and change G_SEXT
to extend from 32 -> 64
?
ErrInfo = "Expected 32/64bit scalar destination"; | ||
return MRI.getType(MI.getOperand(0).getReg()) == LLT::scalar(32) || | ||
MRI.getType(MI.getOperand(0).getReg()) == LLT::scalar(64); | ||
ErrInfo = "Expected 20/32/64bit scalar destination"; |
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: we haven't changed anything for AIE2p, we still expect only 32-/64-bit destination types
const LLT S20 = LLT::scalar(20); | ||
Register DstReg20Bit = MRI.createGenericVirtualRegister(S20); | ||
Register ExtReg20Bit = MRI.createGenericVirtualRegister(S20); | ||
MachineIRBuilder MIRBuilder(MI); |
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.
The Combiner class already has a MachineIRBuilder
member B
, we should use it here to make us of potential CSE opportunities: initialize as B.setInstrAndDebugLoc(MI);
and then use below
@@ -159,8 +159,9 @@ bool AIE2InstrInfo::verifyGenericInstruction(const MachineInstr &MI, | |||
return false; | |||
} | |||
} | |||
ErrInfo = "Expected 32bit scalar destination"; | |||
return MRI.getType(MI.getOperand(0).getReg()) == LLT::scalar(32); | |||
ErrInfo = "Expected 20/32bit scalar destination"; |
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 you please add instruction selection tests for s20 = G_AIE_[SZ]EXT_EXTRACT_VECTOR_ELT
now that we made these new types legal?
MachineVerifier
has been updated to allowG_AIE_SEXT_EXTRACT_VECTOR_ELT
andG_AIE_ZEXT_EXTRACT_VECTOR_ELT
to accept 20-bit outputs.