-
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
[AIE2P] Implemented VLDB.UNPACK combine #299
base: aie-public
Are you sure you want to change the base?
Conversation
837eb63
to
cda5d12
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.
Everything else seems good. The test files need to be checked again once they have been updated.
// Erasing the load instruction breaks later on in the selection code. That is | ||
// because we keep an iterator on erased instructions. This breaks while | ||
// trying to eliminate a trivially dead instruction which requires access to | ||
// its memory operands which have been erased, thus leading to a seg fault. To | ||
// remedy this, we keep the load to be removed by the trivial dead code | ||
// elimination and we make sure to assign a new virtual register definition to | ||
// its live operands to respect SSA. |
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 think at this point, we no longer need this comment, we use makeDeadMI
in multiple instruction selection methods.
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 would rather keep it because if someone reads exactly this function then the comment helps to understand why we do it.
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 explaining it once at the definition of makeDeadMI would suffice. It's just one vscode click away. I also think that the comment is overly woolly. 'We can not erase this since it would invalidate active iterators' says it all.
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.
Similarly to #292, the offsets in the tests need to be updated, because the immediate ranges have changed from AIE2 to AIE2P. Please also fix them in the post-increment test file.
d7580ff
to
0e71576
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.
Please update the year in the file header.
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.
Please update the year in the file header.
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 use AIEBaseInstructionSelector::setCtrlRegister
in selectSetControlRegister
?
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.
As in AIE2InstructionSelector.cpp
: Could you also use AIEBaseInstructionSelector::setCtrlRegister
in selectSetControlRegister
?
@@ -1268,7 +1273,7 @@ bool AIE2PInstructionSelector::selectG_AIE_LOAD_UPS(MachineInstr &UPSI, | |||
|
|||
// First use is the G_INTRINSIC_W_SIDE_EFFECTS ID | |||
Register LoadResult = (std::next(UPSI.uses().begin()))->getReg(); | |||
MachineInstr *LoadOp = MRI.getUniqueVRegDef(LoadResult); | |||
MachineInstr *LoadOp = getDefIgnoringCopiesAndBitcasts(LoadResult, MRI); |
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 add a test for this change?
@@ -2672,7 +2677,7 @@ bool AIE2PInstructionSelector::selectG_AIE_STORE_CONV( | |||
// differ. | |||
|
|||
Register ConvResult = (StoreI.uses().begin())->getReg(); | |||
MachineInstr *ConvOp = MRI.getUniqueVRegDef(ConvResult); | |||
MachineInstr *ConvOp = getDefIgnoringCopiesAndBitcasts(ConvResult, MRI); |
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.
Same thing as above: Could you add a test for this change?
%8:modregbank(s20) = G_CONSTANT i20 0 | ||
%9:modregbank(s20) = G_CONSTANT i20 -256 | ||
%10:modregbank(s20) = G_CONSTANT i20 224 | ||
%11:modregbank(s20) = G_CONSTANT i20 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.
Is there a reason you skipped the offset test with half a step size?
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.
No, I think I just missed it, I added it to the test.
CombOpInstID == Intrinsic::aie2p_unpack_I1024_I8_I4))) && | ||
"Unexpected VLDB.UNPACK size"); | ||
|
||
unsigned ISelOpcode; |
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 would declare a local version where and when it is needed. Otherwise, please initialize it to 'the illegal opcode'
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 cannot create local versions in this case, I would need to give all of them different names, so I initialized it with UINT_MAX
.
? AIE2P::VLDB_UNPACK_dmw_ldb_unpack_idx_imm_unpackSign1 | ||
: AIE2P::VLDB_UNPACK_dmw_ldb_unpack_idx_unpackSign1; | ||
return LoadStoreOpcodes{ISelOpcode, FitsImmediateRange, {}}; | ||
} |
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 know the default case doesn't occur, but could we at least put a break between the cases of the outer switch? (if only to help the poor C++ compiler.)
return false; | ||
|
||
const std::optional<APInt> NoImmediate = {}; | ||
bool IsSigned = false; |
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 bool IsSigned = false;
bool AIE2PInstructionSelector::canCombineUNPACKLoad(MachineInstr &MemOp, | ||
MachineInstr &CombOp, | ||
MachineRegisterInfo &MRI) { | ||
Register LoadResult = (std::next(CombOp.uses().begin()))->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.
I don't understand this. AFAICS, MemOp is the Load. Why isn't LoadResult the register of its first def?
const bool AlwaysFitsImmediateRange = true; | ||
const bool NoImmediate = false; | ||
bool FitsImmediateRange = false; | ||
if (IsSigned) { |
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.
AFAICS, the else branch differs only in selecting a different opcode. I would arrange for that with a small function unsigned selectSignedness(int Opcode, IsSigned)
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.
it is a good idea and I think it makes sense to do it for all combines but for now I would leave it as it is and implement these functions for all combines in a follow-up PR.
0e71576
to
02fcb28
Compare
02fcb28
to
06b250c
Compare
No description provided.