[llvm] 16395da - Revert "[VPlan] Fold VPDef into VPRecipeBase (NFC). (#174282)"
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 24 05:23:17 PST 2026
Author: Florian Hahn
Date: 2026-01-24T13:16:45Z
New Revision: 16395da0ff577750571b99fe28281ce6fb6a3ae8
URL: https://github.com/llvm/llvm-project/commit/16395da0ff577750571b99fe28281ce6fb6a3ae8
DIFF: https://github.com/llvm/llvm-project/commit/16395da0ff577750571b99fe28281ce6fb6a3ae8.diff
LOG: Revert "[VPlan] Fold VPDef into VPRecipeBase (NFC). (#174282)"
This reverts commit f3ae334f4b7a8cf4fe0eb6ee7b2f2ef0879f522d.
Committed with out-of-date message, revert to reland with updated
message.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
llvm/lib/Transforms/Vectorize/VPlanValue.h
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 22861fb796447..21df45d0e647b 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -4120,40 +4120,40 @@ static bool willGenerateVectors(VPlan &Plan, ElementCount VF,
// result. Note that this includes VPInstruction where some opcodes may
// produce a vector, to preserve existing behavior as VPInstructions model
// aspects not directly mapped to existing IR instructions.
- switch (R.getVPRecipeID()) {
- case VPRecipeBase::VPDerivedIVSC:
- case VPRecipeBase::VPScalarIVStepsSC:
- case VPRecipeBase::VPReplicateSC:
- case VPRecipeBase::VPInstructionSC:
- case VPRecipeBase::VPCanonicalIVPHISC:
- case VPRecipeBase::VPVectorPointerSC:
- case VPRecipeBase::VPVectorEndPointerSC:
- case VPRecipeBase::VPExpandSCEVSC:
- case VPRecipeBase::VPEVLBasedIVPHISC:
- case VPRecipeBase::VPPredInstPHISC:
- case VPRecipeBase::VPBranchOnMaskSC:
+ switch (R.getVPDefID()) {
+ case VPDef::VPDerivedIVSC:
+ case VPDef::VPScalarIVStepsSC:
+ case VPDef::VPReplicateSC:
+ case VPDef::VPInstructionSC:
+ case VPDef::VPCanonicalIVPHISC:
+ case VPDef::VPVectorPointerSC:
+ case VPDef::VPVectorEndPointerSC:
+ case VPDef::VPExpandSCEVSC:
+ case VPDef::VPEVLBasedIVPHISC:
+ case VPDef::VPPredInstPHISC:
+ case VPDef::VPBranchOnMaskSC:
continue;
- case VPRecipeBase::VPReductionSC:
- case VPRecipeBase::VPActiveLaneMaskPHISC:
- case VPRecipeBase::VPWidenCallSC:
- case VPRecipeBase::VPWidenCanonicalIVSC:
- case VPRecipeBase::VPWidenCastSC:
- case VPRecipeBase::VPWidenGEPSC:
- case VPRecipeBase::VPWidenIntrinsicSC:
- case VPRecipeBase::VPWidenSC:
- case VPRecipeBase::VPBlendSC:
- case VPRecipeBase::VPFirstOrderRecurrencePHISC:
- case VPRecipeBase::VPHistogramSC:
- case VPRecipeBase::VPWidenPHISC:
- case VPRecipeBase::VPWidenIntOrFpInductionSC:
- case VPRecipeBase::VPWidenPointerInductionSC:
- case VPRecipeBase::VPReductionPHISC:
- case VPRecipeBase::VPInterleaveEVLSC:
- case VPRecipeBase::VPInterleaveSC:
- case VPRecipeBase::VPWidenLoadEVLSC:
- case VPRecipeBase::VPWidenLoadSC:
- case VPRecipeBase::VPWidenStoreEVLSC:
- case VPRecipeBase::VPWidenStoreSC:
+ case VPDef::VPReductionSC:
+ case VPDef::VPActiveLaneMaskPHISC:
+ case VPDef::VPWidenCallSC:
+ case VPDef::VPWidenCanonicalIVSC:
+ case VPDef::VPWidenCastSC:
+ case VPDef::VPWidenGEPSC:
+ case VPDef::VPWidenIntrinsicSC:
+ case VPDef::VPWidenSC:
+ case VPDef::VPBlendSC:
+ case VPDef::VPFirstOrderRecurrencePHISC:
+ case VPDef::VPHistogramSC:
+ case VPDef::VPWidenPHISC:
+ case VPDef::VPWidenIntOrFpInductionSC:
+ case VPDef::VPWidenPointerInductionSC:
+ case VPDef::VPReductionPHISC:
+ case VPDef::VPInterleaveEVLSC:
+ case VPDef::VPInterleaveSC:
+ case VPDef::VPWidenLoadEVLSC:
+ case VPDef::VPWidenLoadSC:
+ case VPDef::VPWidenStoreEVLSC:
+ case VPDef::VPWidenStoreSC:
break;
default:
llvm_unreachable("unhandled recipe");
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index 62a38d7edd51b..876c1cc9df22b 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -111,23 +111,27 @@ void VPValue::dump() const {
dbgs() << "\n";
}
-void VPRecipeBase::dump() const {
- VPSlotTracker SlotTracker(getParent() ? getParent()->getPlan() : nullptr);
+void VPDef::dump() const {
+ const VPRecipeBase *Instr = dyn_cast_or_null<VPRecipeBase>(this);
+ VPSlotTracker SlotTracker(
+ (Instr && Instr->getParent()) ? Instr->getParent()->getPlan() : nullptr);
print(dbgs(), "", SlotTracker);
dbgs() << "\n";
}
#endif
-bool VPRecipeValue::isDefinedBy(const VPDef *D) const { return Def == D; }
-
VPRecipeBase *VPValue::getDefiningRecipe() {
auto *DefValue = dyn_cast<VPRecipeValue>(this);
- return DefValue ? DefValue->Def : nullptr;
+ if (!DefValue)
+ return nullptr;
+ return cast<VPRecipeBase>(DefValue->Def);
}
const VPRecipeBase *VPValue::getDefiningRecipe() const {
auto *DefValue = dyn_cast<VPRecipeValue>(this);
- return DefValue ? DefValue->Def : nullptr;
+ if (!DefValue)
+ return nullptr;
+ return cast<VPRecipeBase>(DefValue->Def);
}
Value *VPValue::getLiveInIRValue() const {
@@ -136,7 +140,7 @@ Value *VPValue::getLiveInIRValue() const {
Type *VPIRValue::getType() const { return getUnderlyingValue()->getType(); }
-VPRecipeValue::VPRecipeValue(VPRecipeBase *Def, Value *UV)
+VPRecipeValue::VPRecipeValue(VPDef *Def, Value *UV)
: VPValue(VPVRecipeValueSC, UV), Def(Def) {
assert(Def && "VPRecipeValue requires a defining recipe");
Def->addDefinedValue(this);
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index f650971c6b397..a3d1bccbc3329 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -388,9 +388,6 @@ class LLVM_ABI_FOR_TEST VPRecipeBase
friend VPBasicBlock;
friend class VPBlockUtils;
- /// Subclass identifier (for isa/dyn_cast).
- const unsigned char SubclassID;
-
/// Each VPRecipe belongs to a single VPBasicBlock.
VPBasicBlock *Parent = nullptr;
@@ -398,60 +395,9 @@ class LLVM_ABI_FOR_TEST VPRecipeBase
DebugLoc DL;
public:
- /// An enumeration for keeping track of the concrete subclass of VPRecipeBase
- /// that is actually instantiated. Values of this enumeration are kept in the
- /// SubclassID field of the VPRecipeBase objects. They are used for concrete
- /// type identification.
- using VPRecipeTy = enum {
- VPBranchOnMaskSC,
- VPDerivedIVSC,
- VPExpandSCEVSC,
- VPExpressionSC,
- VPIRInstructionSC,
- VPInstructionSC,
- VPInterleaveEVLSC,
- VPInterleaveSC,
- VPReductionEVLSC,
- VPReductionSC,
- VPReplicateSC,
- VPScalarIVStepsSC,
- VPVectorPointerSC,
- VPVectorEndPointerSC,
- VPWidenCallSC,
- VPWidenCanonicalIVSC,
- VPWidenCastSC,
- VPWidenGEPSC,
- VPWidenIntrinsicSC,
- VPWidenLoadEVLSC,
- VPWidenLoadSC,
- VPWidenStoreEVLSC,
- VPWidenStoreSC,
- VPWidenSC,
- VPBlendSC,
- VPHistogramSC,
- // START: Phi-like recipes. Need to be kept together.
- VPWidenPHISC,
- VPPredInstPHISC,
- // START: SubclassID for recipes that inherit VPHeaderPHIRecipe.
- // VPHeaderPHIRecipe need to be kept together.
- VPCanonicalIVPHISC,
- VPActiveLaneMaskPHISC,
- VPEVLBasedIVPHISC,
- VPFirstOrderRecurrencePHISC,
- VPWidenIntOrFpInductionSC,
- VPWidenPointerInductionSC,
- VPReductionPHISC,
- // END: SubclassID for recipes that inherit VPHeaderPHIRecipe
- // END: Phi-like recipes
- VPFirstPHISC = VPWidenPHISC,
- VPFirstHeaderPHISC = VPCanonicalIVPHISC,
- VPLastHeaderPHISC = VPReductionPHISC,
- VPLastPHISC = VPReductionPHISC,
- };
-
VPRecipeBase(const unsigned char SC, ArrayRef<VPValue *> Operands,
DebugLoc DL = DebugLoc::getUnknown())
- : VPDef(), VPUser(Operands), SubclassID(SC), DL(DL) {}
+ : VPDef(SC), VPUser(Operands), DL(DL) {}
~VPRecipeBase() override = default;
@@ -504,9 +450,6 @@ class LLVM_ABI_FOR_TEST VPRecipeBase
/// \returns an iterator pointing to the element after the erased one
iplist<VPRecipeBase>::iterator eraseFromParent();
- /// \return an ID for the concrete type of this object.
- unsigned getVPRecipeID() const { return SubclassID; }
-
/// Method to support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const VPDef *D) {
// All VPDefs are also VPRecipeBases.
@@ -542,12 +485,9 @@ class LLVM_ABI_FOR_TEST VPRecipeBase
void setDebugLoc(DebugLoc NewDL) { DL = NewDL; }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- /// Dump the recipe to stderr (for debugging).
- LLVM_ABI_FOR_TEST void dump() const;
-
/// Print the recipe, delegating to printRecipe().
void print(raw_ostream &O, const Twine &Indent,
- VPSlotTracker &SlotTracker) const;
+ VPSlotTracker &SlotTracker) const override final;
#endif
protected:
@@ -566,20 +506,23 @@ class LLVM_ABI_FOR_TEST VPRecipeBase
};
// Helper macro to define common classof implementations for recipes.
-#define VP_CLASSOF_IMPL(VPRecipeID) \
- static inline bool classof(const VPRecipeBase *R) { \
- return R->getVPRecipeID() == VPRecipeID; \
+#define VP_CLASSOF_IMPL(VPDefID) \
+ static inline bool classof(const VPDef *D) { \
+ return D->getVPDefID() == VPDefID; \
} \
static inline bool classof(const VPValue *V) { \
auto *R = V->getDefiningRecipe(); \
- return R && R->getVPRecipeID() == VPRecipeID; \
+ return R && R->getVPDefID() == VPDefID; \
} \
static inline bool classof(const VPUser *U) { \
auto *R = dyn_cast<VPRecipeBase>(U); \
- return R && R->getVPRecipeID() == VPRecipeID; \
+ return R && R->getVPDefID() == VPDefID; \
+ } \
+ static inline bool classof(const VPRecipeBase *R) { \
+ return R->getVPDefID() == VPDefID; \
} \
static inline bool classof(const VPSingleDefRecipe *R) { \
- return R->getVPRecipeID() == VPRecipeID; \
+ return R->getVPDefID() == VPDefID; \
}
/// VPSingleDef is a base class for recipes for modeling a sequence of one or
@@ -596,7 +539,7 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPRecipeValue {
: VPRecipeBase(SC, Operands, DL), VPRecipeValue(this, UV) {}
static inline bool classof(const VPRecipeBase *R) {
- switch (R->getVPRecipeID()) {
+ switch (R->getVPDefID()) {
case VPRecipeBase::VPDerivedIVSC:
case VPRecipeBase::VPEVLBasedIVPHISC:
case VPRecipeBase::VPExpandSCEVSC:
@@ -637,7 +580,7 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPRecipeValue {
// the recipes to be able to make widened loads VPSingleDefRecipes.
return false;
}
- llvm_unreachable("Unhandled VPRecipeID");
+ llvm_unreachable("Unhandled VPDefID");
}
static inline bool classof(const VPUser *U) {
@@ -1034,17 +977,17 @@ struct VPRecipeWithIRFlags : public VPSingleDefRecipe, public VPIRFlags {
: VPSingleDefRecipe(SC, Operands, DL), VPIRFlags(Flags) {}
static inline bool classof(const VPRecipeBase *R) {
- return R->getVPRecipeID() == VPRecipeBase::VPInstructionSC ||
- R->getVPRecipeID() == VPRecipeBase::VPWidenSC ||
- R->getVPRecipeID() == VPRecipeBase::VPWidenGEPSC ||
- R->getVPRecipeID() == VPRecipeBase::VPWidenCallSC ||
- R->getVPRecipeID() == VPRecipeBase::VPWidenCastSC ||
- R->getVPRecipeID() == VPRecipeBase::VPWidenIntrinsicSC ||
- R->getVPRecipeID() == VPRecipeBase::VPReductionSC ||
- R->getVPRecipeID() == VPRecipeBase::VPReductionEVLSC ||
- R->getVPRecipeID() == VPRecipeBase::VPReplicateSC ||
- R->getVPRecipeID() == VPRecipeBase::VPVectorEndPointerSC ||
- R->getVPRecipeID() == VPRecipeBase::VPVectorPointerSC;
+ return R->getVPDefID() == VPRecipeBase::VPInstructionSC ||
+ R->getVPDefID() == VPRecipeBase::VPWidenSC ||
+ R->getVPDefID() == VPRecipeBase::VPWidenGEPSC ||
+ R->getVPDefID() == VPRecipeBase::VPWidenCallSC ||
+ R->getVPDefID() == VPRecipeBase::VPWidenCastSC ||
+ R->getVPDefID() == VPRecipeBase::VPWidenIntrinsicSC ||
+ R->getVPDefID() == VPRecipeBase::VPReductionSC ||
+ R->getVPDefID() == VPRecipeBase::VPReductionEVLSC ||
+ R->getVPDefID() == VPRecipeBase::VPReplicateSC ||
+ R->getVPDefID() == VPRecipeBase::VPVectorEndPointerSC ||
+ R->getVPDefID() == VPRecipeBase::VPVectorPointerSC;
}
static inline bool classof(const VPUser *U) {
@@ -1053,14 +996,15 @@ struct VPRecipeWithIRFlags : public VPSingleDefRecipe, public VPIRFlags {
}
static inline bool classof(const VPValue *V) {
- auto *R = V->getDefiningRecipe();
+ auto *R = dyn_cast_or_null<VPRecipeBase>(V->getDefiningRecipe());
return R && classof(R);
}
VPRecipeWithIRFlags *clone() override = 0;
- static inline bool classof(const VPSingleDefRecipe *R) {
- return classof(static_cast<const VPRecipeBase *>(R));
+ static inline bool classof(const VPSingleDefRecipe *U) {
+ auto *R = dyn_cast<VPRecipeBase>(U);
+ return R && classof(R);
}
void execute(VPTransformState &State) override = 0;
@@ -1287,7 +1231,7 @@ class LLVM_ABI_FOR_TEST VPInstruction : public VPRecipeWithIRFlags,
const VPIRFlags &Flags = {}, const VPIRMetadata &MD = {},
DebugLoc DL = DebugLoc::getUnknown(), const Twine &Name = "");
- VP_CLASSOF_IMPL(VPRecipeBase::VPInstructionSC)
+ VP_CLASSOF_IMPL(VPDef::VPInstructionSC)
VPInstruction *clone() override {
auto *New = new VPInstruction(Opcode, operands(), *this, *this,
@@ -1369,7 +1313,7 @@ class LLVM_ABI_FOR_TEST VPInstruction : public VPRecipeWithIRFlags,
/// 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. Note that there is no separate recipe ID
+/// directly determine the result type. Note that there is no separate VPDef ID
/// for VPInstructionWithType; it shares the same ID as VPInstruction and is
/// distinguished purely by the opcode.
class VPInstructionWithType : public VPInstruction {
@@ -1539,8 +1483,7 @@ class VPIRInstruction : public VPRecipeBase {
/// VPIRInstruction::create() should be used to create VPIRInstructions, as
/// subclasses may need to be created, e.g. VPIRPhi.
VPIRInstruction(Instruction &I)
- : VPRecipeBase(VPRecipeBase::VPIRInstructionSC, ArrayRef<VPValue *>()),
- I(I) {}
+ : VPRecipeBase(VPDef::VPIRInstructionSC, ArrayRef<VPValue *>()), I(I) {}
public:
~VPIRInstruction() override = default;
@@ -1549,7 +1492,7 @@ class VPIRInstruction : public VPRecipeBase {
/// VPIRInstruction.
LLVM_ABI_FOR_TEST static VPIRInstruction *create(Instruction &I);
- VP_CLASSOF_IMPL(VPRecipeBase::VPIRInstructionSC)
+ VP_CLASSOF_IMPL(VPDef::VPIRInstructionSC)
VPIRInstruction *clone() override {
auto *R = create(I);
@@ -1636,7 +1579,7 @@ class LLVM_ABI_FOR_TEST VPWidenRecipe : public VPRecipeWithIRFlags,
VPWidenRecipe(Instruction &I, ArrayRef<VPValue *> Operands,
const VPIRFlags &Flags = {}, const VPIRMetadata &Metadata = {},
DebugLoc DL = {})
- : VPRecipeWithIRFlags(VPRecipeBase::VPWidenSC, Operands, Flags, DL),
+ : VPRecipeWithIRFlags(VPDef::VPWidenSC, Operands, Flags, DL),
VPIRMetadata(Metadata), Opcode(I.getOpcode()) {
setUnderlyingValue(&I);
}
@@ -1648,7 +1591,7 @@ class LLVM_ABI_FOR_TEST VPWidenRecipe : public VPRecipeWithIRFlags,
getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenSC)
+ VP_CLASSOF_IMPL(VPDef::VPWidenSC)
/// Produce a widened instruction using the opcode and operands of the recipe,
/// processing State.VF elements.
@@ -1689,7 +1632,7 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
CastInst *CI = nullptr, const VPIRFlags &Flags = {},
const VPIRMetadata &Metadata = {},
DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeWithIRFlags(VPRecipeBase::VPWidenCastSC, Op, Flags, DL),
+ : VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op, Flags, DL),
VPIRMetadata(Metadata), Opcode(Opcode), ResultTy(ResultTy) {
assert(flagsValidForOpcode(Opcode) &&
"Set flags not supported for the provided opcode");
@@ -1704,7 +1647,7 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
*this, *this, getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenCastSC)
+ VP_CLASSOF_IMPL(VPDef::VPWidenCastSC)
/// Produce widened copies of the cast.
LLVM_ABI_FOR_TEST void execute(VPTransformState &State) override;
@@ -1749,8 +1692,8 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
const VPIRFlags &Flags = {},
const VPIRMetadata &MD = {},
DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeWithIRFlags(VPRecipeBase::VPWidenIntrinsicSC, CallArguments,
- Flags, DL),
+ : VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, Flags,
+ DL),
VPIRMetadata(MD), VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty),
MayReadFromMemory(CI.mayReadFromMemory()),
MayWriteToMemory(CI.mayWriteToMemory()),
@@ -1763,8 +1706,8 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
const VPIRFlags &Flags = {},
const VPIRMetadata &Metadata = {},
DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeWithIRFlags(VPRecipeBase::VPWidenIntrinsicSC, CallArguments,
- Flags, DL),
+ : VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, Flags,
+ DL),
VPIRMetadata(Metadata), VectorIntrinsicID(VectorIntrinsicID),
ResultTy(Ty) {
LLVMContext &Ctx = Ty->getContext();
@@ -1788,7 +1731,7 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata {
*this, *this, getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenIntrinsicSC)
+ VP_CLASSOF_IMPL(VPDef::VPWidenIntrinsicSC)
/// Produce a widened version of the vector intrinsic.
LLVM_ABI_FOR_TEST void execute(VPTransformState &State) override;
@@ -1838,8 +1781,7 @@ class LLVM_ABI_FOR_TEST VPWidenCallRecipe : public VPRecipeWithIRFlags,
ArrayRef<VPValue *> CallArguments,
const VPIRFlags &Flags = {},
const VPIRMetadata &Metadata = {}, DebugLoc DL = {})
- : VPRecipeWithIRFlags(VPRecipeBase::VPWidenCallSC, CallArguments, Flags,
- DL),
+ : VPRecipeWithIRFlags(VPDef::VPWidenCallSC, CallArguments, Flags, DL),
VPIRMetadata(Metadata), Variant(Variant) {
setUnderlyingValue(UV);
assert(
@@ -1854,7 +1796,7 @@ class LLVM_ABI_FOR_TEST VPWidenCallRecipe : public VPRecipeWithIRFlags,
*this, *this, getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenCallSC)
+ VP_CLASSOF_IMPL(VPDef::VPWidenCallSC)
/// Produce a widened version of the call instruction.
void execute(VPTransformState &State) override;
@@ -1890,8 +1832,7 @@ class VPHistogramRecipe : public VPRecipeBase {
public:
VPHistogramRecipe(unsigned Opcode, ArrayRef<VPValue *> Operands,
DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeBase(VPRecipeBase::VPHistogramSC, Operands, DL),
- Opcode(Opcode) {}
+ : VPRecipeBase(VPDef::VPHistogramSC, Operands, DL), Opcode(Opcode) {}
~VPHistogramRecipe() override = default;
@@ -1899,7 +1840,7 @@ class VPHistogramRecipe : public VPRecipeBase {
return new VPHistogramRecipe(Opcode, operands(), getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPHistogramSC);
+ VP_CLASSOF_IMPL(VPDef::VPHistogramSC);
/// Produce a vectorized histogram operation.
void execute(VPTransformState &State) override;
@@ -1940,7 +1881,7 @@ class LLVM_ABI_FOR_TEST VPWidenGEPRecipe : public VPRecipeWithIRFlags {
VPWidenGEPRecipe(GetElementPtrInst *GEP, ArrayRef<VPValue *> Operands,
const VPIRFlags &Flags = {},
DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeWithIRFlags(VPRecipeBase::VPWidenGEPSC, Operands, Flags, DL),
+ : VPRecipeWithIRFlags(VPDef::VPWidenGEPSC, Operands, Flags, DL),
SourceElementTy(GEP->getSourceElementType()) {
setUnderlyingValue(GEP);
SmallVector<std::pair<unsigned, MDNode *>> Metadata;
@@ -1956,7 +1897,7 @@ class LLVM_ABI_FOR_TEST VPWidenGEPRecipe : public VPRecipeWithIRFlags {
operands(), *this, getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenGEPSC)
+ VP_CLASSOF_IMPL(VPDef::VPWidenGEPSC)
/// This recipe generates a GEP instruction.
unsigned getOpcode() const { return Instruction::GetElementPtr; }
@@ -1998,13 +1939,13 @@ class VPVectorEndPointerRecipe : public VPRecipeWithIRFlags,
public:
VPVectorEndPointerRecipe(VPValue *Ptr, VPValue *VF, Type *IndexedTy,
int64_t Stride, GEPNoWrapFlags GEPFlags, DebugLoc DL)
- : VPRecipeWithIRFlags(VPRecipeBase::VPVectorEndPointerSC,
+ : VPRecipeWithIRFlags(VPDef::VPVectorEndPointerSC,
ArrayRef<VPValue *>({Ptr, VF}), GEPFlags, DL),
IndexedTy(IndexedTy), Stride(Stride) {
assert(Stride < 0 && "Stride must be negative");
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPVectorEndPointerSC)
+ VP_CLASSOF_IMPL(VPDef::VPVectorEndPointerSC)
VPValue *getVFValue() { return getOperand(1); }
const VPValue *getVFValue() const { return getOperand(1); }
@@ -2055,10 +1996,10 @@ class VPVectorPointerRecipe : public VPRecipeWithIRFlags {
public:
VPVectorPointerRecipe(VPValue *Ptr, Type *SourceElementTy,
GEPNoWrapFlags GEPFlags, DebugLoc DL)
- : VPRecipeWithIRFlags(VPRecipeBase::VPVectorPointerSC, Ptr, GEPFlags, DL),
+ : VPRecipeWithIRFlags(VPDef::VPVectorPointerSC, Ptr, GEPFlags, DL),
SourceElementTy(SourceElementTy) {}
- VP_CLASSOF_IMPL(VPRecipeBase::VPVectorPointerSC)
+ VP_CLASSOF_IMPL(VPDef::VPVectorPointerSC)
VPValue *getOffset() {
return getNumOperands() == 2 ? getOperand(1) : nullptr;
@@ -2131,9 +2072,9 @@ class VPVectorPointerRecipe : public VPRecipeWithIRFlags {
class LLVM_ABI_FOR_TEST VPHeaderPHIRecipe : public VPSingleDefRecipe,
public VPPhiAccessors {
protected:
- VPHeaderPHIRecipe(unsigned char VPRecipeID, Instruction *UnderlyingInstr,
+ VPHeaderPHIRecipe(unsigned char VPDefID, Instruction *UnderlyingInstr,
VPValue *Start, DebugLoc DL = DebugLoc::getUnknown())
- : VPSingleDefRecipe(VPRecipeID, ArrayRef<VPValue *>({Start}),
+ : VPSingleDefRecipe(VPDefID, ArrayRef<VPValue *>({Start}),
UnderlyingInstr, DL) {}
const VPRecipeBase *getAsRecipe() const override { return this; }
@@ -2143,8 +2084,8 @@ class LLVM_ABI_FOR_TEST VPHeaderPHIRecipe : public VPSingleDefRecipe,
/// Method to support type inquiry through isa, cast, and dyn_cast.
static inline bool classof(const VPRecipeBase *R) {
- return R->getVPRecipeID() >= VPRecipeBase::VPFirstHeaderPHISC &&
- R->getVPRecipeID() <= VPRecipeBase::VPLastHeaderPHISC;
+ return R->getVPDefID() >= VPDef::VPFirstHeaderPHISC &&
+ R->getVPDefID() <= VPDef::VPLastHeaderPHISC;
}
static inline bool classof(const VPValue *V) {
return isa<VPHeaderPHIRecipe>(V->getDefiningRecipe());
@@ -2208,8 +2149,8 @@ class VPWidenInductionRecipe : public VPHeaderPHIRecipe {
}
static inline bool classof(const VPRecipeBase *R) {
- return R->getVPRecipeID() == VPRecipeBase::VPWidenIntOrFpInductionSC ||
- R->getVPRecipeID() == VPRecipeBase::VPWidenPointerInductionSC;
+ return R->getVPDefID() == VPDef::VPWidenIntOrFpInductionSC ||
+ R->getVPDefID() == VPDef::VPWidenPointerInductionSC;
}
static inline bool classof(const VPValue *V) {
@@ -2285,8 +2226,8 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe,
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPIRValue *Start, VPValue *Step,
VPValue *VF, const InductionDescriptor &IndDesc,
const VPIRFlags &Flags, DebugLoc DL)
- : VPWidenInductionRecipe(VPRecipeBase::VPWidenIntOrFpInductionSC, IV,
- Start, Step, IndDesc, DL),
+ : VPWidenInductionRecipe(VPDef::VPWidenIntOrFpInductionSC, IV, Start,
+ Step, IndDesc, DL),
VPIRFlags(Flags), Trunc(nullptr) {
addOperand(VF);
}
@@ -2295,8 +2236,8 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe,
VPValue *VF, const InductionDescriptor &IndDesc,
TruncInst *Trunc, const VPIRFlags &Flags,
DebugLoc DL)
- : VPWidenInductionRecipe(VPRecipeBase::VPWidenIntOrFpInductionSC, IV,
- Start, Step, IndDesc, DL),
+ : VPWidenInductionRecipe(VPDef::VPWidenIntOrFpInductionSC, IV, Start,
+ Step, IndDesc, DL),
VPIRFlags(Flags), Trunc(Trunc) {
addOperand(VF);
SmallVector<std::pair<unsigned, MDNode *>> Metadata;
@@ -2314,7 +2255,7 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe,
getInductionDescriptor(), Trunc, *this, getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenIntOrFpInductionSC)
+ VP_CLASSOF_IMPL(VPDef::VPWidenIntOrFpInductionSC)
void execute(VPTransformState &State) override {
llvm_unreachable("cannot execute this recipe, should be expanded via "
@@ -2373,8 +2314,8 @@ class VPWidenPointerInductionRecipe : public VPWidenInductionRecipe {
VPWidenPointerInductionRecipe(PHINode *Phi, VPValue *Start, VPValue *Step,
VPValue *NumUnrolledElems,
const InductionDescriptor &IndDesc, DebugLoc DL)
- : VPWidenInductionRecipe(VPRecipeBase::VPWidenPointerInductionSC, Phi,
- Start, Step, IndDesc, DL) {
+ : VPWidenInductionRecipe(VPDef::VPWidenPointerInductionSC, Phi, Start,
+ Step, IndDesc, DL) {
addOperand(NumUnrolledElems);
}
@@ -2386,7 +2327,7 @@ class VPWidenPointerInductionRecipe : public VPWidenInductionRecipe {
getOperand(2), getInductionDescriptor(), getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenPointerInductionSC)
+ VP_CLASSOF_IMPL(VPDef::VPWidenPointerInductionSC)
/// Generate vector values for the pointer induction.
void execute(VPTransformState &State) override {
@@ -2420,8 +2361,7 @@ class LLVM_ABI_FOR_TEST VPWidenPHIRecipe : public VPSingleDefRecipe,
/// debug location \p DL.
VPWidenPHIRecipe(PHINode *Phi, VPValue *Start = nullptr,
DebugLoc DL = DebugLoc::getUnknown(), const Twine &Name = "")
- : VPSingleDefRecipe(VPRecipeBase::VPWidenPHISC, {}, Phi, DL),
- Name(Name.str()) {
+ : VPSingleDefRecipe(VPDef::VPWidenPHISC, {}, Phi, DL), Name(Name.str()) {
if (Start)
addOperand(Start);
}
@@ -2436,7 +2376,7 @@ class LLVM_ABI_FOR_TEST VPWidenPHIRecipe : public VPSingleDefRecipe,
~VPWidenPHIRecipe() override = default;
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenPHISC)
+ VP_CLASSOF_IMPL(VPDef::VPWidenPHISC)
/// Generate the phi/select nodes.
void execute(VPTransformState &State) override;
@@ -2461,12 +2401,11 @@ class LLVM_ABI_FOR_TEST VPWidenPHIRecipe : public VPSingleDefRecipe,
struct VPFirstOrderRecurrencePHIRecipe : public VPHeaderPHIRecipe {
VPFirstOrderRecurrencePHIRecipe(PHINode *Phi, VPValue &Start,
VPValue &BackedgeValue)
- : VPHeaderPHIRecipe(VPRecipeBase::VPFirstOrderRecurrencePHISC, Phi,
- &Start) {
+ : VPHeaderPHIRecipe(VPDef::VPFirstOrderRecurrencePHISC, Phi, &Start) {
addOperand(&BackedgeValue);
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPFirstOrderRecurrencePHISC)
+ VP_CLASSOF_IMPL(VPDef::VPFirstOrderRecurrencePHISC)
VPFirstOrderRecurrencePHIRecipe *clone() override {
return new VPFirstOrderRecurrencePHIRecipe(
@@ -2538,8 +2477,8 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe,
VPReductionPHIRecipe(PHINode *Phi, RecurKind Kind, VPValue &Start,
VPValue &BackedgeValue, ReductionStyle Style,
bool HasUsesOutsideReductionChain = false)
- : VPHeaderPHIRecipe(VPRecipeBase::VPReductionPHISC, Phi, &Start),
- Kind(Kind), Style(Style),
+ : VPHeaderPHIRecipe(VPDef::VPReductionPHISC, Phi, &Start), Kind(Kind),
+ Style(Style),
HasUsesOutsideReductionChain(HasUsesOutsideReductionChain) {
addOperand(&BackedgeValue);
}
@@ -2553,7 +2492,7 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe,
HasUsesOutsideReductionChain);
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPReductionPHISC)
+ VP_CLASSOF_IMPL(VPDef::VPReductionPHISC)
/// Generate the phi/select nodes.
void execute(VPTransformState &State) override;
@@ -2621,7 +2560,7 @@ class LLVM_ABI_FOR_TEST VPBlendRecipe : public VPSingleDefRecipe {
/// be omitted (implied by passing an odd number of operands) in which case
/// all other incoming values are merged into it.
VPBlendRecipe(PHINode *Phi, ArrayRef<VPValue *> Operands, DebugLoc DL)
- : VPSingleDefRecipe(VPRecipeBase::VPBlendSC, Operands, Phi, DL) {
+ : VPSingleDefRecipe(VPDef::VPBlendSC, Operands, Phi, DL) {
assert(Operands.size() >= 2 && "Expected at least two operands!");
}
@@ -2630,7 +2569,7 @@ class LLVM_ABI_FOR_TEST VPBlendRecipe : public VPSingleDefRecipe {
operands(), getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPBlendSC)
+ VP_CLASSOF_IMPL(VPDef::VPBlendSC)
/// A normalized blend is one that has an odd number of operands, whereby the
/// first operand does not have an associated mask.
@@ -2733,8 +2672,8 @@ class LLVM_ABI_FOR_TEST VPInterleaveBase : public VPRecipeBase,
VPInterleaveBase *clone() override = 0;
static inline bool classof(const VPRecipeBase *R) {
- return R->getVPRecipeID() == VPRecipeBase::VPInterleaveSC ||
- R->getVPRecipeID() == VPRecipeBase::VPInterleaveEVLSC;
+ return R->getVPDefID() == VPRecipeBase::VPInterleaveSC ||
+ R->getVPDefID() == VPRecipeBase::VPInterleaveEVLSC;
}
static inline bool classof(const VPUser *U) {
@@ -2794,8 +2733,8 @@ class LLVM_ABI_FOR_TEST VPInterleaveRecipe final : public VPInterleaveBase {
VPInterleaveRecipe(const InterleaveGroup<Instruction> *IG, VPValue *Addr,
ArrayRef<VPValue *> StoredValues, VPValue *Mask,
bool NeedsMaskForGaps, const VPIRMetadata &MD, DebugLoc DL)
- : VPInterleaveBase(VPRecipeBase::VPInterleaveSC, IG, Addr, StoredValues,
- Mask, NeedsMaskForGaps, MD, DL) {}
+ : VPInterleaveBase(VPDef::VPInterleaveSC, IG, Addr, StoredValues, Mask,
+ NeedsMaskForGaps, MD, DL) {}
~VPInterleaveRecipe() override = default;
@@ -2805,7 +2744,7 @@ class LLVM_ABI_FOR_TEST VPInterleaveRecipe final : public VPInterleaveBase {
needsMaskForGaps(), *this, getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPInterleaveSC)
+ VP_CLASSOF_IMPL(VPDef::VPInterleaveSC)
/// Generate the wide load or store, and shuffles.
void execute(VPTransformState &State) override;
@@ -2834,10 +2773,10 @@ class LLVM_ABI_FOR_TEST VPInterleaveRecipe final : public VPInterleaveBase {
class LLVM_ABI_FOR_TEST VPInterleaveEVLRecipe final : public VPInterleaveBase {
public:
VPInterleaveEVLRecipe(VPInterleaveRecipe &R, VPValue &EVL, VPValue *Mask)
- : VPInterleaveBase(
- VPRecipeBase::VPInterleaveEVLSC, R.getInterleaveGroup(),
- ArrayRef<VPValue *>({R.getAddr(), &EVL}), R.getStoredValues(), Mask,
- R.needsMaskForGaps(), R, R.getDebugLoc()) {
+ : VPInterleaveBase(VPDef::VPInterleaveEVLSC, R.getInterleaveGroup(),
+ ArrayRef<VPValue *>({R.getAddr(), &EVL}),
+ R.getStoredValues(), Mask, R.needsMaskForGaps(), R,
+ R.getDebugLoc()) {
assert(!getInterleaveGroup()->isReverse() &&
"Reversed interleave-group with tail folding is not supported.");
assert(!needsMaskForGaps() && "Interleaved access with gap mask is not "
@@ -2850,7 +2789,7 @@ class LLVM_ABI_FOR_TEST VPInterleaveEVLRecipe final : public VPInterleaveBase {
llvm_unreachable("cloning not implemented yet");
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPInterleaveEVLSC)
+ VP_CLASSOF_IMPL(VPDef::VPInterleaveEVLSC)
/// The VPValue of the explicit vector length.
VPValue *getEVL() const { return getOperand(1); }
@@ -2908,14 +2847,14 @@ class LLVM_ABI_FOR_TEST VPReductionRecipe : public VPRecipeWithIRFlags {
VPReductionRecipe(RecurKind RdxKind, FastMathFlags FMFs, Instruction *I,
VPValue *ChainOp, VPValue *VecOp, VPValue *CondOp,
ReductionStyle Style, DebugLoc DL = DebugLoc::getUnknown())
- : VPReductionRecipe(VPRecipeBase::VPReductionSC, RdxKind, FMFs, I,
+ : VPReductionRecipe(VPDef::VPReductionSC, RdxKind, FMFs, I,
ArrayRef<VPValue *>({ChainOp, VecOp}), CondOp, Style,
DL) {}
VPReductionRecipe(const RecurKind RdxKind, FastMathFlags FMFs,
VPValue *ChainOp, VPValue *VecOp, VPValue *CondOp,
ReductionStyle Style, DebugLoc DL = DebugLoc::getUnknown())
- : VPReductionRecipe(VPRecipeBase::VPReductionSC, RdxKind, FMFs, nullptr,
+ : VPReductionRecipe(VPDef::VPReductionSC, RdxKind, FMFs, nullptr,
ArrayRef<VPValue *>({ChainOp, VecOp}), CondOp, Style,
DL) {}
@@ -2928,8 +2867,8 @@ class LLVM_ABI_FOR_TEST VPReductionRecipe : public VPRecipeWithIRFlags {
}
static inline bool classof(const VPRecipeBase *R) {
- return R->getVPRecipeID() == VPRecipeBase::VPReductionSC ||
- R->getVPRecipeID() == VPRecipeBase::VPReductionEVLSC;
+ return R->getVPDefID() == VPRecipeBase::VPReductionSC ||
+ R->getVPDefID() == VPRecipeBase::VPReductionEVLSC;
}
static inline bool classof(const VPUser *U) {
@@ -2998,7 +2937,7 @@ class LLVM_ABI_FOR_TEST VPReductionEVLRecipe : public VPReductionRecipe {
VPReductionEVLRecipe(VPReductionRecipe &R, VPValue &EVL, VPValue *CondOp,
DebugLoc DL = DebugLoc::getUnknown())
: VPReductionRecipe(
- VPRecipeBase::VPReductionEVLSC, R.getRecurrenceKind(),
+ VPDef::VPReductionEVLSC, R.getRecurrenceKind(),
R.getFastMathFlags(),
cast_or_null<Instruction>(R.getUnderlyingValue()),
ArrayRef<VPValue *>({R.getChainOp(), R.getVecOp(), &EVL}), CondOp,
@@ -3010,7 +2949,7 @@ class LLVM_ABI_FOR_TEST VPReductionEVLRecipe : public VPReductionRecipe {
llvm_unreachable("cloning not implemented yet");
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPReductionEVLSC)
+ VP_CLASSOF_IMPL(VPDef::VPReductionEVLSC)
/// Generate the reduction in the loop
void execute(VPTransformState &State) override;
@@ -3050,7 +2989,7 @@ class LLVM_ABI_FOR_TEST VPReplicateRecipe : public VPRecipeWithIRFlags,
bool IsSingleScalar, VPValue *Mask = nullptr,
const VPIRFlags &Flags = {}, VPIRMetadata Metadata = {},
DebugLoc DL = DebugLoc::getUnknown())
- : VPRecipeWithIRFlags(VPRecipeBase::VPReplicateSC, Operands, Flags, DL),
+ : VPRecipeWithIRFlags(VPDef::VPReplicateSC, Operands, Flags, DL),
VPIRMetadata(Metadata), IsSingleScalar(IsSingleScalar),
IsPredicated(Mask) {
setUnderlyingValue(I);
@@ -3068,7 +3007,7 @@ class LLVM_ABI_FOR_TEST VPReplicateRecipe : public VPRecipeWithIRFlags,
return Copy;
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPReplicateSC)
+ VP_CLASSOF_IMPL(VPDef::VPReplicateSC)
/// Generate replicas of the desired Ingredient. Replicas will be generated
/// for all parts and lanes unless a specific part and lane are specified in
@@ -3122,13 +3061,13 @@ class LLVM_ABI_FOR_TEST VPReplicateRecipe : public VPRecipeWithIRFlags,
class LLVM_ABI_FOR_TEST VPBranchOnMaskRecipe : public VPRecipeBase {
public:
VPBranchOnMaskRecipe(VPValue *BlockInMask, DebugLoc DL)
- : VPRecipeBase(VPRecipeBase::VPBranchOnMaskSC, {BlockInMask}, DL) {}
+ : VPRecipeBase(VPDef::VPBranchOnMaskSC, {BlockInMask}, DL) {}
VPBranchOnMaskRecipe *clone() override {
return new VPBranchOnMaskRecipe(getOperand(0), getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPBranchOnMaskSC)
+ VP_CLASSOF_IMPL(VPDef::VPBranchOnMaskSC)
/// Generate the extraction of the appropriate bit from the block mask and the
/// conditional branch.
@@ -3237,7 +3176,7 @@ class VPExpressionRecipe : public VPSingleDefRecipe {
delete T;
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPExpressionSC)
+ VP_CLASSOF_IMPL(VPDef::VPExpressionSC)
VPExpressionRecipe *clone() override {
assert(!ExpressionRecipes.empty() && "empty expressions should be removed");
@@ -3311,14 +3250,14 @@ class LLVM_ABI_FOR_TEST VPPredInstPHIRecipe : public VPSingleDefRecipe {
/// Construct a VPPredInstPHIRecipe given \p PredInst whose value needs a phi
/// nodes after merging back from a Branch-on-Mask.
VPPredInstPHIRecipe(VPValue *PredV, DebugLoc DL)
- : VPSingleDefRecipe(VPRecipeBase::VPPredInstPHISC, PredV, DL) {}
+ : VPSingleDefRecipe(VPDef::VPPredInstPHISC, PredV, DL) {}
~VPPredInstPHIRecipe() override = default;
VPPredInstPHIRecipe *clone() override {
return new VPPredInstPHIRecipe(getOperand(0), getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPPredInstPHISC)
+ VP_CLASSOF_IMPL(VPDef::VPPredInstPHISC)
/// Generates phi nodes for live-outs (from a replicate region) as needed to
/// retain SSA form.
@@ -3391,10 +3330,10 @@ class LLVM_ABI_FOR_TEST VPWidenMemoryRecipe : public VPRecipeBase,
}
static inline bool classof(const VPRecipeBase *R) {
- return R->getVPRecipeID() == VPRecipeBase::VPWidenLoadSC ||
- R->getVPRecipeID() == VPRecipeBase::VPWidenStoreSC ||
- R->getVPRecipeID() == VPRecipeBase::VPWidenLoadEVLSC ||
- R->getVPRecipeID() == VPRecipeBase::VPWidenStoreEVLSC;
+ return R->getVPDefID() == VPRecipeBase::VPWidenLoadSC ||
+ R->getVPDefID() == VPRecipeBase::VPWidenStoreSC ||
+ R->getVPDefID() == VPRecipeBase::VPWidenLoadEVLSC ||
+ R->getVPDefID() == VPRecipeBase::VPWidenStoreEVLSC;
}
static inline bool classof(const VPUser *U) {
@@ -3444,8 +3383,8 @@ struct LLVM_ABI_FOR_TEST VPWidenLoadRecipe final : public VPWidenMemoryRecipe,
VPWidenLoadRecipe(LoadInst &Load, VPValue *Addr, VPValue *Mask,
bool Consecutive, bool Reverse,
const VPIRMetadata &Metadata, DebugLoc DL)
- : VPWidenMemoryRecipe(VPRecipeBase::VPWidenLoadSC, Load, {Addr},
- Consecutive, Reverse, Metadata, DL),
+ : VPWidenMemoryRecipe(VPDef::VPWidenLoadSC, Load, {Addr}, Consecutive,
+ Reverse, Metadata, DL),
VPRecipeValue(this, &Load) {
setMask(Mask);
}
@@ -3456,7 +3395,7 @@ struct LLVM_ABI_FOR_TEST VPWidenLoadRecipe final : public VPWidenMemoryRecipe,
getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenLoadSC);
+ VP_CLASSOF_IMPL(VPDef::VPWidenLoadSC);
/// Generate a wide load or gather.
void execute(VPTransformState &State) override;
@@ -3485,14 +3424,14 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe,
public VPRecipeValue {
VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue *Addr, VPValue &EVL,
VPValue *Mask)
- : VPWidenMemoryRecipe(VPRecipeBase::VPWidenLoadEVLSC, L.getIngredient(),
+ : VPWidenMemoryRecipe(VPDef::VPWidenLoadEVLSC, L.getIngredient(),
{Addr, &EVL}, L.isConsecutive(), L.isReverse(), L,
L.getDebugLoc()),
VPRecipeValue(this, &getIngredient()) {
setMask(Mask);
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenLoadEVLSC)
+ VP_CLASSOF_IMPL(VPDef::VPWidenLoadEVLSC)
/// Return the EVL operand.
VPValue *getEVL() const { return getOperand(1); }
@@ -3527,9 +3466,8 @@ struct LLVM_ABI_FOR_TEST VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
VPWidenStoreRecipe(StoreInst &Store, VPValue *Addr, VPValue *StoredVal,
VPValue *Mask, bool Consecutive, bool Reverse,
const VPIRMetadata &Metadata, DebugLoc DL)
- : VPWidenMemoryRecipe(VPRecipeBase::VPWidenStoreSC, Store,
- {Addr, StoredVal}, Consecutive, Reverse, Metadata,
- DL) {
+ : VPWidenMemoryRecipe(VPDef::VPWidenStoreSC, Store, {Addr, StoredVal},
+ Consecutive, Reverse, Metadata, DL) {
setMask(Mask);
}
@@ -3539,7 +3477,7 @@ struct LLVM_ABI_FOR_TEST VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
Reverse, *this, getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenStoreSC);
+ VP_CLASSOF_IMPL(VPDef::VPWidenStoreSC);
/// Return the value stored by this recipe.
VPValue *getStoredValue() const { return getOperand(1); }
@@ -3570,13 +3508,13 @@ struct LLVM_ABI_FOR_TEST VPWidenStoreRecipe final : public VPWidenMemoryRecipe {
struct VPWidenStoreEVLRecipe final : public VPWidenMemoryRecipe {
VPWidenStoreEVLRecipe(VPWidenStoreRecipe &S, VPValue *Addr,
VPValue *StoredVal, VPValue &EVL, VPValue *Mask)
- : VPWidenMemoryRecipe(VPRecipeBase::VPWidenStoreEVLSC, S.getIngredient(),
+ : VPWidenMemoryRecipe(VPDef::VPWidenStoreEVLSC, S.getIngredient(),
{Addr, StoredVal, &EVL}, S.isConsecutive(),
S.isReverse(), S, S.getDebugLoc()) {
setMask(Mask);
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenStoreEVLSC)
+ VP_CLASSOF_IMPL(VPDef::VPWidenStoreEVLSC)
/// Return the address accessed by this recipe.
VPValue *getStoredValue() const { return getOperand(1); }
@@ -3619,13 +3557,13 @@ class VPExpandSCEVRecipe : public VPSingleDefRecipe {
public:
VPExpandSCEVRecipe(const SCEV *Expr)
- : VPSingleDefRecipe(VPRecipeBase::VPExpandSCEVSC, {}), Expr(Expr) {}
+ : VPSingleDefRecipe(VPDef::VPExpandSCEVSC, {}), Expr(Expr) {}
~VPExpandSCEVRecipe() override = default;
VPExpandSCEVRecipe *clone() override { return new VPExpandSCEVRecipe(Expr); }
- VP_CLASSOF_IMPL(VPRecipeBase::VPExpandSCEVSC)
+ VP_CLASSOF_IMPL(VPDef::VPExpandSCEVSC)
void execute(VPTransformState &State) override {
llvm_unreachable("SCEV expressions must be expanded before final execute");
@@ -3655,8 +3593,7 @@ class VPExpandSCEVRecipe : public VPSingleDefRecipe {
class VPCanonicalIVPHIRecipe : public VPHeaderPHIRecipe {
public:
VPCanonicalIVPHIRecipe(VPIRValue *StartV, DebugLoc DL)
- : VPHeaderPHIRecipe(VPRecipeBase::VPCanonicalIVPHISC, nullptr, StartV,
- DL) {}
+ : VPHeaderPHIRecipe(VPDef::VPCanonicalIVPHISC, nullptr, StartV, DL) {}
~VPCanonicalIVPHIRecipe() override = default;
@@ -3666,7 +3603,7 @@ class VPCanonicalIVPHIRecipe : public VPHeaderPHIRecipe {
return R;
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPCanonicalIVPHISC)
+ VP_CLASSOF_IMPL(VPDef::VPCanonicalIVPHISC)
void execute(VPTransformState &State) override {
llvm_unreachable("cannot execute this recipe, should be replaced by a "
@@ -3713,8 +3650,8 @@ class VPCanonicalIVPHIRecipe : public VPHeaderPHIRecipe {
class VPActiveLaneMaskPHIRecipe : public VPHeaderPHIRecipe {
public:
VPActiveLaneMaskPHIRecipe(VPValue *StartMask, DebugLoc DL)
- : VPHeaderPHIRecipe(VPRecipeBase::VPActiveLaneMaskPHISC, nullptr,
- StartMask, DL) {}
+ : VPHeaderPHIRecipe(VPDef::VPActiveLaneMaskPHISC, nullptr, StartMask,
+ DL) {}
~VPActiveLaneMaskPHIRecipe() override = default;
@@ -3725,7 +3662,7 @@ class VPActiveLaneMaskPHIRecipe : public VPHeaderPHIRecipe {
return R;
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPActiveLaneMaskPHISC)
+ VP_CLASSOF_IMPL(VPDef::VPActiveLaneMaskPHISC)
/// Generate the active lane mask phi of the vector loop.
void execute(VPTransformState &State) override;
@@ -3745,8 +3682,7 @@ class VPActiveLaneMaskPHIRecipe : public VPHeaderPHIRecipe {
class VPEVLBasedIVPHIRecipe : public VPHeaderPHIRecipe {
public:
VPEVLBasedIVPHIRecipe(VPValue *StartIV, DebugLoc DL)
- : VPHeaderPHIRecipe(VPRecipeBase::VPEVLBasedIVPHISC, nullptr, StartIV,
- DL) {}
+ : VPHeaderPHIRecipe(VPDef::VPEVLBasedIVPHISC, nullptr, StartIV, DL) {}
~VPEVLBasedIVPHIRecipe() override = default;
@@ -3754,7 +3690,7 @@ class VPEVLBasedIVPHIRecipe : public VPHeaderPHIRecipe {
llvm_unreachable("cloning not implemented yet");
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPEVLBasedIVPHISC)
+ VP_CLASSOF_IMPL(VPDef::VPEVLBasedIVPHISC)
void execute(VPTransformState &State) override {
llvm_unreachable("cannot execute this recipe, should be replaced by a "
@@ -3788,7 +3724,7 @@ class VPWidenCanonicalIVRecipe : public VPSingleDefRecipe,
public VPUnrollPartAccessor<1> {
public:
VPWidenCanonicalIVRecipe(VPCanonicalIVPHIRecipe *CanonicalIV)
- : VPSingleDefRecipe(VPRecipeBase::VPWidenCanonicalIVSC, {CanonicalIV}) {}
+ : VPSingleDefRecipe(VPDef::VPWidenCanonicalIVSC, {CanonicalIV}) {}
~VPWidenCanonicalIVRecipe() override = default;
@@ -3797,7 +3733,7 @@ class VPWidenCanonicalIVRecipe : public VPSingleDefRecipe,
cast<VPCanonicalIVPHIRecipe>(getOperand(0)));
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPWidenCanonicalIVSC)
+ VP_CLASSOF_IMPL(VPDef::VPWidenCanonicalIVSC)
/// Generate a canonical vector induction variable of the vector loop, with
/// start = {<Part*VF, Part*VF+1, ..., Part*VF+VF-1> for 0 <= Part < UF}, and
@@ -3844,8 +3780,8 @@ class VPDerivedIVRecipe : public VPSingleDefRecipe {
VPDerivedIVRecipe(InductionDescriptor::InductionKind Kind,
const FPMathOperator *FPBinOp, VPIRValue *Start,
VPValue *IV, VPValue *Step, const Twine &Name = "")
- : VPSingleDefRecipe(VPRecipeBase::VPDerivedIVSC, {Start, IV, Step}),
- Kind(Kind), FPBinOp(FPBinOp), Name(Name.str()) {}
+ : VPSingleDefRecipe(VPDef::VPDerivedIVSC, {Start, IV, Step}), Kind(Kind),
+ FPBinOp(FPBinOp), Name(Name.str()) {}
~VPDerivedIVRecipe() override = default;
@@ -3854,7 +3790,7 @@ class VPDerivedIVRecipe : public VPSingleDefRecipe {
getStepValue());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPDerivedIVSC)
+ VP_CLASSOF_IMPL(VPDef::VPDerivedIVSC)
/// Generate the transformed value of the induction at offset StartValue (1.
/// operand) + IV (2. operand) * StepValue (3, operand).
@@ -3901,7 +3837,7 @@ class LLVM_ABI_FOR_TEST VPScalarIVStepsRecipe : public VPRecipeWithIRFlags {
VPScalarIVStepsRecipe(VPValue *IV, VPValue *Step, VPValue *VF,
Instruction::BinaryOps Opcode, FastMathFlags FMFs,
DebugLoc DL)
- : VPRecipeWithIRFlags(VPRecipeBase::VPScalarIVStepsSC,
+ : VPRecipeWithIRFlags(VPDef::VPScalarIVStepsSC,
ArrayRef<VPValue *>({IV, Step, VF}), FMFs, DL),
InductionOpcode(Opcode) {}
@@ -3924,7 +3860,7 @@ class LLVM_ABI_FOR_TEST VPScalarIVStepsRecipe : public VPRecipeWithIRFlags {
getDebugLoc());
}
- VP_CLASSOF_IMPL(VPRecipeBase::VPScalarIVStepsSC)
+ VP_CLASSOF_IMPL(VPDef::VPScalarIVStepsSC)
/// Generate the scalarized versions of the phi node as needed by their users.
void execute(VPTransformState &State) override;
@@ -3981,12 +3917,12 @@ struct CastInfoVPPhiAccessors : public CastIsPossible<VPPhiAccessors, SrcTy> {
/// doCast is used by cast<>.
static inline VPPhiAccessors *doCast(SrcTy R) {
return const_cast<VPPhiAccessors *>([R]() -> const VPPhiAccessors * {
- switch (R->getVPRecipeID()) {
- case VPRecipeBase::VPInstructionSC:
+ switch (R->getVPDefID()) {
+ case VPDef::VPInstructionSC:
return cast<VPPhi>(R);
- case VPRecipeBase::VPIRInstructionSC:
+ case VPDef::VPIRInstructionSC:
return cast<VPIRPhi>(R);
- case VPRecipeBase::VPWidenPHISC:
+ case VPDef::VPWidenPHISC:
return cast<VPWidenPHIRecipe>(R);
default:
return cast<VPHeaderPHIRecipe>(R);
@@ -4013,26 +3949,26 @@ struct CastInfo<VPPhiAccessors, const VPRecipeBase *>
namespace detail {
template <typename DstTy, typename RecipeBasePtrTy>
static inline auto castToVPIRMetadata(RecipeBasePtrTy R) -> DstTy {
- switch (R->getVPRecipeID()) {
- case VPRecipeBase::VPInstructionSC:
+ switch (R->getVPDefID()) {
+ case VPDef::VPInstructionSC:
return cast<VPInstruction>(R);
- case VPRecipeBase::VPWidenSC:
+ case VPDef::VPWidenSC:
return cast<VPWidenRecipe>(R);
- case VPRecipeBase::VPWidenCastSC:
+ case VPDef::VPWidenCastSC:
return cast<VPWidenCastRecipe>(R);
- case VPRecipeBase::VPWidenIntrinsicSC:
+ case VPDef::VPWidenIntrinsicSC:
return cast<VPWidenIntrinsicRecipe>(R);
- case VPRecipeBase::VPWidenCallSC:
+ case VPDef::VPWidenCallSC:
return cast<VPWidenCallRecipe>(R);
- case VPRecipeBase::VPReplicateSC:
+ case VPDef::VPReplicateSC:
return cast<VPReplicateRecipe>(R);
- case VPRecipeBase::VPInterleaveSC:
- case VPRecipeBase::VPInterleaveEVLSC:
+ case VPDef::VPInterleaveSC:
+ case VPDef::VPInterleaveEVLSC:
return cast<VPInterleaveBase>(R);
- case VPRecipeBase::VPWidenLoadSC:
- case VPRecipeBase::VPWidenLoadEVLSC:
- case VPRecipeBase::VPWidenStoreSC:
- case VPRecipeBase::VPWidenStoreEVLSC:
+ case VPDef::VPWidenLoadSC:
+ case VPDef::VPWidenLoadEVLSC:
+ case VPDef::VPWidenStoreSC:
+ case VPDef::VPWidenStoreEVLSC:
return cast<VPWidenMemoryRecipe>(R);
default:
llvm_unreachable("invalid recipe for VPIRMetadata cast");
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 3ca27a2802444..1a387ab6f1bd6 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -48,7 +48,7 @@ using VectorParts = SmallVector<Value *, 2>;
#define DEBUG_TYPE LV_NAME
bool VPRecipeBase::mayWriteToMemory() const {
- switch (getVPRecipeID()) {
+ switch (getVPDefID()) {
case VPExpressionSC:
return cast<VPExpressionRecipe>(this)->mayReadOrWriteMemory();
case VPInstructionSC: {
@@ -107,7 +107,7 @@ bool VPRecipeBase::mayWriteToMemory() const {
}
bool VPRecipeBase::mayReadFromMemory() const {
- switch (getVPRecipeID()) {
+ switch (getVPDefID()) {
case VPExpressionSC:
return cast<VPExpressionRecipe>(this)->mayReadOrWriteMemory();
case VPInstructionSC:
@@ -157,7 +157,7 @@ bool VPRecipeBase::mayReadFromMemory() const {
}
bool VPRecipeBase::mayHaveSideEffects() const {
- switch (getVPRecipeID()) {
+ switch (getVPDefID()) {
case VPExpressionSC:
return cast<VPExpressionRecipe>(this)->mayHaveSideEffects();
case VPDerivedIVSC:
@@ -302,7 +302,7 @@ InstructionCost VPRecipeBase::computeCost(ElementCount VF,
}
bool VPRecipeBase::isPhi() const {
- return (getVPRecipeID() >= VPFirstPHISC && getVPRecipeID() <= VPLastPHISC) ||
+ return (getVPDefID() >= VPFirstPHISC && getVPDefID() <= VPLastPHISC) ||
isa<VPPhi, VPIRPhi>(this);
}
@@ -378,7 +378,7 @@ FastMathFlags VPIRFlags::getFastMathFlags() const {
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
-void VPSingleDefRecipe::dump() const { VPRecipeBase::dump(); }
+void VPSingleDefRecipe::dump() const { VPDef::dump(); }
void VPRecipeBase::print(raw_ostream &O, const Twine &Indent,
VPSlotTracker &SlotTracker) const {
@@ -417,7 +417,7 @@ template class VPUnrollPartAccessor<3>;
VPInstruction::VPInstruction(unsigned Opcode, ArrayRef<VPValue *> Operands,
const VPIRFlags &Flags, const VPIRMetadata &MD,
DebugLoc DL, const Twine &Name)
- : VPRecipeWithIRFlags(VPRecipeBase::VPInstructionSC, Operands, Flags, DL),
+ : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, Flags, DL),
VPIRMetadata(MD), Opcode(Opcode), Name(Name.str()) {
assert(flagsValidForOpcode(getOpcode()) &&
"Set flags not supported for the provided opcode");
@@ -2826,7 +2826,7 @@ InstructionCost VPReductionRecipe::computeCost(ElementCount VF,
VPExpressionRecipe::VPExpressionRecipe(
ExpressionTypes ExpressionType,
ArrayRef<VPSingleDefRecipe *> ExpressionRecipes)
- : VPSingleDefRecipe(VPRecipeBase::VPExpressionSC, {}, {}),
+ : VPSingleDefRecipe(VPDef::VPExpressionSC, {}, {}),
ExpressionRecipes(ExpressionRecipes), ExpressionType(ExpressionType) {
assert(!ExpressionRecipes.empty() && "Nothing to combine?");
assert(
diff --git a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
index d1d5870d78a03..1b78bfac4f007 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
@@ -1118,9 +1118,9 @@ getOpcodeOrIntrinsicID(const VPSingleDefRecipe *R) {
.Case<VPVectorPointerRecipe, VPPredInstPHIRecipe>([](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 VPRecipeID.
+ // after the last IR Instruction opcode), based on the VPDefID.
return std::make_pair(false,
- VPInstruction::OpsEnd + 1 + I->getVPRecipeID());
+ VPInstruction::OpsEnd + 1 + I->getVPDefID());
})
.Default([](auto *) { return std::nullopt; });
}
@@ -2452,7 +2452,7 @@ struct VPCSEDenseMapInfo : public DenseMapInfo<VPSingleDefRecipe *> {
const VPlan *Plan = Def->getParent()->getPlan();
VPTypeAnalysis TypeInfo(*Plan);
hash_code Result = hash_combine(
- Def->getVPRecipeID(), getOpcodeOrIntrinsicID(Def),
+ Def->getVPDefID(), getOpcodeOrIntrinsicID(Def),
getGEPSourceElementType(Def), TypeInfo.inferScalarType(Def),
vputils::isSingleScalar(Def), hash_combine_range(Def->operands()));
if (auto *RFlags = dyn_cast<VPRecipeWithIRFlags>(Def))
@@ -2465,7 +2465,7 @@ struct VPCSEDenseMapInfo : public DenseMapInfo<VPSingleDefRecipe *> {
static bool isEqual(const VPSingleDefRecipe *L, const VPSingleDefRecipe *R) {
if (isSentinel(L) || isSentinel(R))
return L == R;
- if (L->getVPRecipeID() != R->getVPRecipeID() ||
+ if (L->getVPDefID() != R->getVPDefID() ||
getOpcodeOrIntrinsicID(L) != getOpcodeOrIntrinsicID(R) ||
getGEPSourceElementType(L) != getGEPSourceElementType(R) ||
vputils::isSingleScalar(L) != vputils::isSingleScalar(R) ||
diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index 4ef78341e0654..b24c40f0326a1 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -35,6 +35,7 @@ class raw_ostream;
class Type;
class Value;
class VPDef;
+struct VPDoubleValueDef;
class VPSlotTracker;
class VPUser;
class VPRecipeBase;
@@ -44,6 +45,8 @@ class VPPhiAccessors;
/// data flow into, within and out of the VPlan. VPValues can stand for live-ins
/// coming from the input IR, symbolic values and values defined by recipes.
class LLVM_ABI_FOR_TEST VPValue {
+ friend class VPDef;
+ friend struct VPDoubleValueDef;
friend class VPlan;
friend struct VPIRValue;
friend struct VPSymbolicValue;
@@ -232,19 +235,11 @@ struct VPSymbolicValue : public VPValue {
class VPRecipeValue : public VPValue {
friend class VPValue;
friend class VPDef;
-
- /// Pointer to the VPRecipeBase that defines this VPValue.
- VPRecipeBase *Def;
-
-#if !defined(NDEBUG)
- /// Returns true if this VPRecipeValue is defined by \p D.
- /// NOTE: Only used by VPDef to assert that VPRecipeValues added/removed from
- /// /p D are associated with its VPRecipeBase,
- bool isDefinedBy(const VPDef *D) const;
-#endif
+ /// Pointer to the VPDef that defines this VPValue.
+ VPDef *Def;
public:
- LLVM_ABI_FOR_TEST VPRecipeValue(VPRecipeBase *Def, Value *UV = nullptr);
+ LLVM_ABI_FOR_TEST VPRecipeValue(VPDef *Def, Value *UV = nullptr);
LLVM_ABI_FOR_TEST virtual ~VPRecipeValue();
@@ -359,14 +354,18 @@ class VPUser {
/// Single-value VPDefs that also inherit from VPValue must make sure to inherit
/// from VPDef before VPValue.
class VPDef {
+ friend class VPValue;
friend class VPRecipeValue;
+ /// Subclass identifier (for isa/dyn_cast).
+ const unsigned char SubclassID;
+
/// The VPValues defined by this VPDef.
TinyPtrVector<VPRecipeValue *> DefinedValues;
/// Add \p V as a defined value by this VPDef.
void addDefinedValue(VPRecipeValue *V) {
- assert(V->isDefinedBy(this) &&
+ assert(V->Def == this &&
"can only add VPValue already linked with this VPDef");
DefinedValues.push_back(V);
}
@@ -374,8 +373,7 @@ class VPDef {
/// Remove \p V from the values defined by this VPDef. \p V must be a defined
/// value of this VPDef.
void removeDefinedValue(VPRecipeValue *V) {
- assert(V->isDefinedBy(this) &&
- "can only remove VPValue linked with this VPDef");
+ assert(V->Def == this && "can only remove VPValue linked with this VPDef");
assert(is_contained(DefinedValues, V) &&
"VPValue to remove must be in DefinedValues");
llvm::erase(DefinedValues, V);
@@ -383,11 +381,62 @@ class VPDef {
}
public:
- VPDef() {}
+ /// An enumeration for keeping track of the concrete subclass of VPRecipeBase
+ /// that is actually instantiated. Values of this enumeration are kept in the
+ /// SubclassID field of the VPRecipeBase objects. They are used for concrete
+ /// type identification.
+ using VPRecipeTy = enum {
+ VPBranchOnMaskSC,
+ VPDerivedIVSC,
+ VPExpandSCEVSC,
+ VPExpressionSC,
+ VPIRInstructionSC,
+ VPInstructionSC,
+ VPInterleaveEVLSC,
+ VPInterleaveSC,
+ VPReductionEVLSC,
+ VPReductionSC,
+ VPReplicateSC,
+ VPScalarIVStepsSC,
+ VPVectorPointerSC,
+ VPVectorEndPointerSC,
+ VPWidenCallSC,
+ VPWidenCanonicalIVSC,
+ VPWidenCastSC,
+ VPWidenGEPSC,
+ VPWidenIntrinsicSC,
+ VPWidenLoadEVLSC,
+ VPWidenLoadSC,
+ VPWidenStoreEVLSC,
+ VPWidenStoreSC,
+ VPWidenSC,
+ VPBlendSC,
+ VPHistogramSC,
+ // START: Phi-like recipes. Need to be kept together.
+ VPWidenPHISC,
+ VPPredInstPHISC,
+ // START: SubclassID for recipes that inherit VPHeaderPHIRecipe.
+ // VPHeaderPHIRecipe need to be kept together.
+ VPCanonicalIVPHISC,
+ VPActiveLaneMaskPHISC,
+ VPEVLBasedIVPHISC,
+ VPFirstOrderRecurrencePHISC,
+ VPWidenIntOrFpInductionSC,
+ VPWidenPointerInductionSC,
+ VPReductionPHISC,
+ // END: SubclassID for recipes that inherit VPHeaderPHIRecipe
+ // END: Phi-like recipes
+ VPFirstPHISC = VPWidenPHISC,
+ VPFirstHeaderPHISC = VPCanonicalIVPHISC,
+ VPLastHeaderPHISC = VPReductionPHISC,
+ VPLastPHISC = VPReductionPHISC,
+ };
+
+ VPDef(const unsigned char SC) : SubclassID(SC) {}
virtual ~VPDef() {
for (VPRecipeValue *D : to_vector(DefinedValues)) {
- assert(D->isDefinedBy(this) &&
+ assert(D->Def == this &&
"all defined VPValues should point to the containing VPDef");
assert(D->getNumUsers() == 0 &&
"all defined VPValues should have no more users");
@@ -425,6 +474,20 @@ class VPDef {
/// Returns the number of values defined by the VPDef.
unsigned getNumDefinedValues() const { return DefinedValues.size(); }
+
+ /// \return an ID for the concrete type of this object.
+ /// This is used to implement the classof checks. This should not be used
+ /// for any other purpose, as the values may change as LLVM evolves.
+ unsigned getVPDefID() const { return SubclassID; }
+
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
+ /// Dump the VPDef to stderr (for debugging).
+ LLVM_ABI_FOR_TEST void dump() const;
+
+ /// Each concrete VPDef prints itself.
+ virtual void print(raw_ostream &O, const Twine &Indent,
+ VPSlotTracker &SlotTracker) const = 0;
+#endif
};
} // namespace llvm
diff --git a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
index 9b1e7c0af7c8c..b49c57a1332cf 100644
--- a/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
+++ b/llvm/unittests/Transforms/Vectorize/VPlanTest.cpp
@@ -1015,7 +1015,7 @@ TEST_F(VPRecipeTest, CastVPWidenRecipeToVPUser) {
delete AI;
}
-TEST_F(VPRecipeTest, CastVPWidenCallRecipeToVPUserAndVPRecipeBase) {
+TEST_F(VPRecipeTest, CastVPWidenCallRecipeToVPUserAndVPDef) {
VPlan &Plan = getPlan();
IntegerType *Int32 = IntegerType::get(C, 32);
FunctionType *FTy = FunctionType::get(Int32, false);
@@ -1056,6 +1056,7 @@ TEST_F(VPRecipeTest, CastVPWidenGEPRecipeToVPUserAndVPDef) {
checkVPRecipeCastImpl<VPWidenGEPRecipe, VPUser>(&Recipe);
VPValue *VPV = &Recipe;
+ EXPECT_TRUE(isa<VPRecipeBase>(VPV->getDefiningRecipe()));
EXPECT_EQ(&Recipe, VPV->getDefiningRecipe());
delete GEP;
@@ -1140,7 +1141,7 @@ TEST_F(VPRecipeTest, CastVPBranchOnMaskRecipeToVPUser) {
checkVPRecipeCastImpl<VPBranchOnMaskRecipe, VPUser>(&Recipe);
}
-TEST_F(VPRecipeTest, CastVPWidenMemoryRecipeToVPUserAndVPRecipeBase) {
+TEST_F(VPRecipeTest, CastVPWidenMemoryRecipeToVPUserAndVPDef) {
VPlan &Plan = getPlan();
IntegerType *Int32 = IntegerType::get(C, 32);
PointerType *Int32Ptr = PointerType::get(C, 0);
@@ -1153,6 +1154,7 @@ TEST_F(VPRecipeTest, CastVPWidenMemoryRecipeToVPUserAndVPRecipeBase) {
checkVPRecipeCastImpl<VPWidenLoadRecipe, VPUser, VPIRMetadata>(&Recipe);
VPValue *VPV = Recipe.getVPSingleValue();
+ EXPECT_TRUE(isa<VPRecipeBase>(VPV->getDefiningRecipe()));
EXPECT_EQ(&Recipe, VPV->getDefiningRecipe());
delete Load;
@@ -1430,7 +1432,7 @@ TEST_F(VPRecipeTest, dumpRecipeInPlan) {
},
testing::ExitedWithCode(0), "WIDEN ir<%a> = add ir<1>, ir<2>");
- VPRecipeBase *Def = WidenR;
+ VPDef *Def = WidenR;
EXPECT_EXIT(
{
Def->dump();
@@ -1453,6 +1455,15 @@ TEST_F(VPRecipeTest, dumpRecipeInPlan) {
exit(0);
},
testing::ExitedWithCode(0), "WIDEN ir<%a> = add ir<1>, ir<2>");
+
+ // Test VPDef::dump().
+ VPDef *D = WidenR;
+ EXPECT_EXIT(
+ {
+ D->dump();
+ exit(0);
+ },
+ testing::ExitedWithCode(0), "WIDEN ir<%a> = add ir<1>, ir<2>");
}
delete AI;
@@ -1500,6 +1511,15 @@ TEST_F(VPRecipeTest, dumpRecipeUnnamedVPValuesInPlan) {
exit(0);
},
testing::ExitedWithCode(0), "EMIT vp<%1> = add ir<1>, ir<%a>");
+
+ // Test VPDef::dump().
+ VPDef *D = I1;
+ EXPECT_EXIT(
+ {
+ D->dump();
+ exit(0);
+ },
+ testing::ExitedWithCode(0), "EMIT vp<%1> = add ir<1>, ir<%a>");
}
// Check printing I2.
{
@@ -1522,6 +1542,15 @@ TEST_F(VPRecipeTest, dumpRecipeUnnamedVPValuesInPlan) {
exit(0);
},
testing::ExitedWithCode(0), "EMIT vp<%2> = mul vp<%1>, vp<%1>");
+
+ // Test VPDef::dump().
+ VPDef *D = I2;
+ EXPECT_EXIT(
+ {
+ D->dump();
+ exit(0);
+ },
+ testing::ExitedWithCode(0), "EMIT vp<%2> = mul vp<%1>, vp<%1>");
}
delete AI;
}
@@ -1558,6 +1587,15 @@ TEST_F(VPRecipeTest, dumpRecipeUnnamedVPValuesNotInPlanOrBlock) {
exit(0);
},
testing::ExitedWithCode(0), "EMIT <badref> = add ir<1>, ir<%a>");
+
+ // Test VPDef::dump().
+ VPDef *D = I1;
+ EXPECT_EXIT(
+ {
+ D->dump();
+ exit(0);
+ },
+ testing::ExitedWithCode(0), "EMIT <badref> = add ir<1>, ir<%a>");
}
// Check printing I2.
{
@@ -1580,6 +1618,15 @@ TEST_F(VPRecipeTest, dumpRecipeUnnamedVPValuesNotInPlanOrBlock) {
exit(0);
},
testing::ExitedWithCode(0), "EMIT <badref> = mul <badref>, <badref>");
+
+ // Test VPDef::dump().
+ VPDef *D = I2;
+ EXPECT_EXIT(
+ {
+ D->dump();
+ exit(0);
+ },
+ testing::ExitedWithCode(0), "EMIT <badref> = mul <badref>, <badref>");
}
delete I2;
@@ -1636,7 +1683,7 @@ TEST(VPDoubleValueDefTest, traverseUseLists) {
// Check that the def-use chains of a multi-def can be traversed in both
// directions.
- // Create a new VPRecipeBase which defines 2 values and has 2 operands.
+ // Create a new VPDef which defines 2 values and has 2 operands.
VPInstruction Op0(VPInstruction::StepVector, {});
VPInstruction Op1(VPInstruction::VScale, {});
VPDoubleValueDef DoubleValueDef({&Op0, &Op1});
@@ -1647,7 +1694,7 @@ TEST(VPDoubleValueDefTest, traverseUseLists) {
VPInstruction I2(Instruction::Freeze, {DoubleValueDef.getVPValue(0)});
VPInstruction I3(Instruction::Freeze, {DoubleValueDef.getVPValue(1)});
- // Check operands of the VPRecipeBase (traversing upwards).
+ // Check operands of the VPDef (traversing upwards).
SmallVector<VPValue *, 4> DoubleOperands(DoubleValueDef.op_begin(),
DoubleValueDef.op_end());
EXPECT_EQ(2u, DoubleOperands.size());
@@ -1669,7 +1716,7 @@ TEST(VPDoubleValueDefTest, traverseUseLists) {
EXPECT_EQ(&I1, DoubleValueDefV1Users[0]);
EXPECT_EQ(&I3, DoubleValueDefV1Users[1]);
- // Now check that we can get the right VPRecipeBase for each defined value.
+ // Now check that we can get the right VPDef for each defined value.
EXPECT_EQ(&DoubleValueDef, I1.getOperand(0)->getDefiningRecipe());
EXPECT_EQ(&DoubleValueDef, I1.getOperand(1)->getDefiningRecipe());
EXPECT_EQ(&DoubleValueDef, I2.getOperand(0)->getDefiningRecipe());
More information about the llvm-commits
mailing list