-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[VPlan] Assign custom opcodes to recipes not mapping to IR opcodes. #162267
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
Changes from 1 commit
dfcbf78
6d74fd4
1a28ac3
74eee17
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1982,6 +1982,13 @@ struct VPCSEDenseMapInfo : public DenseMapInfo<VPSingleDefRecipe *> { | |||||||||
| .Case<VPWidenIntrinsicRecipe>([](auto *I) { | ||||||||||
| return std::make_pair(true, I->getVectorIntrinsicID()); | ||||||||||
| }) | ||||||||||
| .Case<VPVectorPointerRecipe>([](auto *I) { | ||||||||||
| // For recipes that do not directly map to LLVM IR instructions, | ||||||||||
| // assign opcodes after the last VPInstruction opcode (which is also | ||||||||||
| // after the last IR Instruction opcode), based on the VPDefID. | ||||||||||
| return std::make_pair(false, | ||||||||||
| VPInstruction::OpsEnd + 1 + I->getVPDefID()); | ||||||||||
| }) | ||||||||||
| .Default([](auto *) { return std::nullopt; }); | ||||||||||
| } | ||||||||||
|
|
||||||||||
|
|
@@ -2005,12 +2012,9 @@ struct VPCSEDenseMapInfo : public DenseMapInfo<VPSingleDefRecipe *> { | |||||||||
| static bool canHandle(const VPSingleDefRecipe *Def) { | ||||||||||
| // We can extend the list of handled recipes in the future, | ||||||||||
| // provided we account for the data embedded in them while checking for | ||||||||||
| // equality or hashing. We assign VPVectorEndPointerRecipe the GEP opcode, | ||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this potentially changes behavior rather than purely NFC, as VPVectorEndPointerRecipe and GEP are now distinct?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We check the subclass ID in addition to the opcode while performing CSE, so this change would be non-functional.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this checking of subclass ID redundant now, and can be replaced by an assert that the subclass ID's are the same if their opcodes are?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is still needed now, as this prevents replacing for example VPWidenRecipe BinOps with VPReplicateRecipe BinOps. This would be taken care of if we include VPDefID for all opcodes, but we would need some kind of total order for VPDefIDs and their start and end opcodes, for all recipes.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Understood. Making getOpcode/OrIntrinsicID unique across recipes could also be taken care of by consolidating conflicting recipes, so that information about widening vs. replication (as in the example) is encoded elsewhere, e.g., in the type of the operands, if not in the opcode itself. |
||||||||||
| // as it is essentially a GEP with different semantics. | ||||||||||
| auto C = isa<VPVectorPointerRecipe>(Def) | ||||||||||
| ? std::make_pair(false, Instruction::GetElementPtr) | ||||||||||
| : getOpcodeOrIntrinsicID(Def); | ||||||||||
| // equality or hashing. | ||||||||||
|
|
||||||||||
| auto C = getOpcodeOrIntrinsicID(Def); | ||||||||||
|
||||||||||
| auto C = getOpcodeOrIntrinsicID(Def); | |
| auto C = getOpcodeOrIntrinsicID(Def); | |
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.
Should be adjusted, thanks
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.
Alternatively, an opcode can be added for VPVectorPointerRecipe, similar to various VPInstructions. OTOH, this offers a systematic way of providing opcodes to all recipes, aiming to also support VPPredInstPHI. Having a universal opcode across all recipes would require addressing multiple recipes with potentially common underlying opcodes.
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 initially added the GEP opcode to VPVectorPointerRecipe, but @fhahn said that it other users could potentially conflate a VectorPointer with a plain GEP, causing confusion. I think adding opcodes to the remaining recipes as
OpsEnd + 1 + getVPDefID()could be interesting.