-
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
[AIEX] Fix ExpandPostRAPseudos and PostSelectOptimize passes to satisfy MachineVerifier #349
Conversation
e685ee2
to
33118de
Compare
// AIE's PseudoMove instruction takes compound register classes which | ||
// contains registers of different sizes. We need to use the right classes | ||
// to avoid the MachineVerifier complaining about mismatching sizes. | ||
auto ConstrainAddrRegClass = [&](Register Reg) { |
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.
Maybe just:
return (MRI.constrainRegClass(Reg, TRI->getAddrAs32BitDCRegClass()) ||
MRI.constrainRegClass(Reg, TRI->getAddrAs32BitDNRegClass()) ||
MRI.constrainRegClass(Reg, TRI->getAddrAs32BitDJRegClass()) ||
MRI.constrainRegClass(Reg, TRI->getAddrAs32BitMRegClass()) ||
MRI.constrainRegClass(Reg, TRI->getAddrAs32BitPRegClass()));
@@ -1162,8 +1162,7 @@ bool AIE2PInstrInfo::expandPostRAPseudo(MachineInstr &MI) const { | |||
case AIE2P::PseudoMove: { | |||
Register Dst = MI.getOperand(0).getReg(); | |||
Register Src = MI.getOperand(1).getReg(); | |||
BuildMI(MBB, MI, DL, get(AIE2P::MOV_alu_mv_mv_mv_scl), Dst) | |||
.addReg(Src, getKillRegState(true)); | |||
BuildMI(MBB, MI, DL, get(AIE2P::MOV_alu_mv_mv_mv_scl), Dst).addReg(Src); |
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.
What about keeping the existing state, like getKillRegState(MI.getOperand(1).isKill())
?
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 guess we can't steal/copy the entire Src operand, even if we throw it away in the next line?
MRI.constrainRegClass(Reg, TRI->getAddrAs32BitDNRegClass()) || | ||
MRI.constrainRegClass(Reg, TRI->getAddrAs32BitDJRegClass()) || | ||
MRI.constrainRegClass(Reg, TRI->getAddrAs32BitMRegClass()) || | ||
MRI.constrainRegClass(Reg, TRI->getAddrAs32BitPRegClass())) |
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 think M, N and J are enough here.
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.
Removed P but kept C
Nice investigation! I would like recommend two things:
|
@@ -28,7 +28,7 @@ body: | | |||
%1:accregbank(<64 x s32>) = COPY $dm0 | |||
%2:vregbank(<64 x s8>) = COPY $x1 | |||
%3:gprregbank(<8 x s8>) = COPY $e1 | |||
%0:vregbank(<64 x s8>), %4:gprregbank(<8 x s8>) = G_INTRINSIC_W_SIDE_EFFECTS intrinsic(@llvm.aie2p.v64accfloat.to.v64bfp16ebs16), %2(<64 x s8>), %3(<8 x s8>), %1(<64 x s32>) |
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.
Random copy paste junk? Do we still need %3 and %1?
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, this test was wrong. I fixed it. The input should have been a copy of $dm0 not $x1. the verify doesn't detect such problems :/
} | ||
virtual const TargetRegisterClass *getAddrAs32BitDCRegClass() const { | ||
llvm_unreachable("Target didn't implement getAddrAs32BitDCRegClass!"); | ||
} |
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: It looks as if these may be AIE2XX specific. Perhaps put the entire constrain sequence in a virtual method, like constrainSubwordRegister?
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 like this idea. +1.
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.
Done
33118de
to
c9293ea
Compare
// contains registers of different sizes. We need to use the right classes | ||
// to avoid the MachineVerifier complaining about mismatching sizes. | ||
assert(TRI->constrainAddrRegClass(MRI, Reg) && | ||
"Expected an addressing register class"); |
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'm not sure I understand the need for a new hook. Why can't we do the same as in ISel and constrain the operands to the largest superclass of the existing class, and the one in the instruction descriptor? We would then get a 32-bit class, because MvScl
class is a compound 32-bit class.
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.
You are right. I updated to use constrainSelectedInstRegOperands
73599c8
to
7e17de8
Compare
7e17de8
to
ed08029
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.
No description provided.