Skip to content
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

Merged
merged 2 commits into from
Feb 5, 2025
Merged

Conversation

katerynamuts
Copy link
Collaborator

No description provided.

Copy link
Collaborator

@mludevid mludevid left a 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.

Comment on lines 2869 to 2997
// 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.
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

@martien-de-jong martien-de-jong Jan 28, 2025

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.

Copy link
Collaborator

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.

@katerynamuts katerynamuts force-pushed the kmuts.vldb-unpack branch 2 times, most recently from d7580ff to 0e71576 Compare January 24, 2025 08:15
Copy link
Collaborator

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.

Copy link
Collaborator

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.

@@ -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);
Copy link
Collaborator

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);
Copy link
Collaborator

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?

Comment on lines 40 to 43
%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
Copy link
Collaborator

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?

Copy link
Collaborator Author

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;
Copy link
Collaborator

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'

Copy link
Collaborator Author

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.

Copy link
Collaborator

@martien-de-jong martien-de-jong Feb 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think block scope was invented for that. But I see it's not your fault...

return false;

const std::optional<APInt> NoImmediate = {};
bool IsSigned = false;
Copy link
Collaborator

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();
Copy link
Collaborator

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?

@katerynamuts katerynamuts force-pushed the kmuts.vldb-unpack branch 2 times, most recently from 06b250c to ef82938 Compare February 3, 2025 10:47
MachineInstrBuilder MI =
MIB.buildInstr(AIE2P::MOV_scalar_imm11_pseudo, {CtrlReg}, {})
.addImm(SrcConstVal);
MachineInstrBuilder MI = setCtrlRegister(MIB, CtrlReg, SrcConstVal);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip: This set of changes might have comprised a separate commit.

@katerynamuts katerynamuts merged commit 2a13d9b into aie-public Feb 5, 2025
8 checks passed
@katerynamuts katerynamuts deleted the kmuts.vldb-unpack branch February 5, 2025 15:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants