-
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] Combine VST.PUSH.CONV #351
base: aie-public
Are you sure you want to change the base?
Conversation
@@ -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 && |
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.
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(); |
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.
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.
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.
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()
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 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(); |
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.
Curious: what happens with operand 6?
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.
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 { |
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 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 {}; |
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: return std::nullopt
Add VST.PUSH.CONV combine in AIE2PInstructionSelector
Modify VST.FLUSH to VST.FLUSH.CONV in AIEPostSelectOptimize
Corresponding MIR tests were added