[llvm] [VPlan] Introduce VPInstructionWithType, use instead of VPScalarCast(NFC) (PR #129706)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 9 14:50:08 PDT 2025
================
@@ -1023,6 +1022,56 @@ class VPInstruction : public VPRecipeWithIRFlags,
/// Returns the symbolic name assigned to the VPInstruction.
StringRef getName() const { return Name; }
+
+ /// Return true if \p U is a cast.
+ static bool isCast(const VPUser *U) {
+ auto *VPI = dyn_cast<VPInstruction>(U);
+ return VPI && Instruction::isCast(VPI->getOpcode());
+ }
+};
+
+/// A specialization of VPInstruction augmenting it with a dedicated result
+/// type, to be used when the opcode and operands of the VPInstruction don't
+/// directly determine the result type.
+class VPInstructionWithType : public VPInstruction {
+ /// Scalar result type produced by the recipe.
+ Type *ResultTy;
+
+public:
+ VPInstructionWithType(unsigned Opcode, ArrayRef<VPValue *> Operands,
+ Type *ResultTy, DebugLoc DL, const Twine &Name = "")
+ : VPInstruction(Opcode, Operands, DL, Name), ResultTy(ResultTy) {}
+
+ static inline bool classof(const VPRecipeBase *R) { return isCast(R); }
----------------
ayalz wrote:
Currently VPInstructionWithType is used for cast recipes only, but if/when that changes the `return isCast(R)` here should be updated. Some comment should be added to explain that all VPInstructionWithType recipes should be identified here based on their opcode, rather than by checking VPDefID, because the latter is VPInstructionSC rather than VPInstructionWithTypeSC.
https://github.com/llvm/llvm-project/pull/129706
More information about the llvm-commits
mailing list