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] Combine VST.PUSH.CONV #351

Open
wants to merge 2 commits into
base: aie-public
Choose a base branch
from

Conversation

abhinay-anubola
Copy link
Collaborator

Add VST.PUSH.CONV combine in AIE2PInstructionSelector
Modify VST.FLUSH to VST.FLUSH.CONV in AIEPostSelectOptimize
Corresponding MIR tests were added

@@ -3635,15 +3636,27 @@ std::optional<LoadStoreOpcodes> AIE2PInstructionSelector::getCombinedOpcodeCONV(
(cast<GIntrinsic>(CombOp).getIntrinsicID() !=
Intrinsic::aie2p_v16accfloat_to_v16bf16 &&
cast<GIntrinsic>(CombOp).getIntrinsicID() !=
Intrinsic::aie2p_v32accfloat_to_v32bf16))
Intrinsic::aie2p_v32accfloat_to_v32bf16 &&
Copy link
Collaborator

Choose a reason for hiding this comment

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

May I suggest to split this check using an extra early return, then get the intrinsicid in a separate variable and use that for the rest of the function.

bool AIE2PInstructionSelector::selectVST_FIFO_CONV(MachineInstr &StoreI,
MachineRegisterInfo &MRI) {
// First use is IntrinsicID and the second is PtrReg
Register ConvResult = (std::next(StoreI.uses().begin(), 2))->getReg();
Copy link
Collaborator

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

Choose a reason for hiding this comment

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

Given that you retrieve PtrIn below as StorI.getOperand(4).getReg(), I think it would be clearer if you would address ConvResult as StoreI.getOperand(5).getReg() here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

When we use Operand 5 its breaking because fifo.st.flush.3d Operand 5 is IntrinsicId.
Maybe we need to have extra check for instructions, If we want to address as StoreI.getOperand(5).getReg()

Copy link
Collaborator

Choose a reason for hiding this comment

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

You are saying that somewhere up the call tree two different builtin signatures can be passed to the same function as StoreI. The order of the uses is luckily the same. I would really handle those two signatures in two different functions.

Register AvailOut = StoreI.getOperand(2).getReg();

Register PtrIn = StoreI.getOperand(4).getReg();
Register FifoIn = StoreI.getOperand(7).getReg();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Curious: what happens with operand 6?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here Operand 5 and 6 are Mantissa and Exponent which are ConvResults. As VST and CONV are combined now, so passing SrcReg of CONV to VST.CONV

.addImm(AIE2P::sub_bfp16_x)
.addReg(ExpIn)
.addImm(AIE2P::sub_bfp16_e);
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be nice to have an assert as to what ConvOp is at this point. It looks as if it is implicit from getCombinedOpcodeCONV

case AIE2P::VST_FLUSH_512_3D:
return AIE2P::VST_FLUSH_512_CONV_3D;
}
return {};
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: return std::nullopt

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.

3 participants