[llvm] [VPlan] Verify dominance for incoming values of phi-like recipes. (PR #124838)
via llvm-commits
llvm-commits at lists.llvm.org
Wed May 14 07:33:04 PDT 2025
================
@@ -3283,6 +3295,48 @@ class VPScalarIVStepsRecipe : public VPRecipeWithIRFlags,
}
};
+/// Casting from VPRecipeBase -> VPPhiAccessors is supported for all recipe
+/// types implementing VPPhiAccessors.
+template <> struct CastIsPossible<VPPhiAccessors, const VPRecipeBase *> {
+ static inline bool isPossible(const VPRecipeBase *f) {
+ return isa<VPIRPhi, VPHeaderPHIRecipe, VPWidenPHIRecipe, VPPhi>(f);
+ }
+};
+/// Support casting from VPRecipeBase -> VPPhiAccessors, by down-casting to the
+/// recipe types implementing VPPhiAccessors.
+template <>
+struct CastInfo<VPPhiAccessors, const VPRecipeBase *>
+ : public CastIsPossible<VPPhiAccessors, const VPRecipeBase *> {
+
+ using Self = CastInfo<VPPhiAccessors, const VPRecipeBase *>;
+
+ using CastReturnType =
+ typename cast_retty<VPPhiAccessors, VPRecipeBase *>::ret_type;
+
+ static inline VPPhiAccessors *doCast(const VPRecipeBase *R) {
+ return const_cast<VPPhiAccessors *>([R]() -> const VPPhiAccessors * {
+ switch (R->getVPDefID()) {
+ case VPDef::VPInstructionSC:
+ return cast<VPPhi>(R);
+ case VPDef::VPIRInstructionSC:
+ return cast<VPIRPhi>(R);
+ case VPDef::VPWidenPHISC:
+ return cast<VPWidenPHIRecipe>(R);
+ default:
+ return cast<VPHeaderPHIRecipe>(R);
+ }
+ }());
+ }
+
+ static inline VPPhiAccessors *castFailed() { return nullptr; }
+
+ static inline VPPhiAccessors *doCastIfPossible(const VPRecipeBase *f) {
----------------
ayalz wrote:
Where is doCastIfPossible used?
https://github.com/llvm/llvm-project/pull/124838
More information about the llvm-commits
mailing list