diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 3f1e12e5d1cd0..eb177b6af639e 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -4111,40 +4111,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.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: + 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: continue; - 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: + 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: break; default: llvm_unreachable("unhandled recipe"); diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp index a6a46e36b397d..6cd828e8c2db8 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -107,27 +107,23 @@ void VPValue::dump() const { dbgs() << "\n"; } -void VPDef::dump() const { - const VPRecipeBase *Instr = dyn_cast_or_null(this); - VPSlotTracker SlotTracker( - (Instr && Instr->getParent()) ? Instr->getParent()->getPlan() : nullptr); +void VPRecipeBase::dump() const { + VPSlotTracker SlotTracker(getParent() ? 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(this); - if (!DefValue) - return nullptr; - return cast(DefValue->Def); + return DefValue ? DefValue->Def : nullptr; } const VPRecipeBase *VPValue::getDefiningRecipe() const { auto *DefValue = dyn_cast(this); - if (!DefValue) - return nullptr; - return cast(DefValue->Def); + return DefValue ? DefValue->Def : nullptr; } Value *VPValue::getLiveInIRValue() const { @@ -136,7 +132,7 @@ Value *VPValue::getLiveInIRValue() const { Type *VPIRValue::getType() const { return getUnderlyingValue()->getType(); } -VPRecipeValue::VPRecipeValue(VPDef *Def, Value *UV) +VPRecipeValue::VPRecipeValue(VPRecipeBase *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 1d250322ccf63..c51ac4ad4f4fd 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -378,8 +378,8 @@ class LLVM_ABI_FOR_TEST VPBlockBase { /// VPRecipeBase is a base class modeling a sequence of one or more output IR /// instructions. VPRecipeBase owns the VPValues it defines through VPDef -/// and is responsible for deleting its defined values. Single-value -/// recipes must inherit from VPSingleDef instead of inheriting from both +/// and is responsible for deleting its defined values. Single-value recipes +/// must inherit from VPSingleDefRecipe instead of inheriting from both /// VPRecipeBase and VPValue separately. class LLVM_ABI_FOR_TEST VPRecipeBase : public ilist_node_with_parent, @@ -388,6 +388,9 @@ 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; @@ -395,9 +398,61 @@ 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, + VPWidenSelectSC, + 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 Operands, DebugLoc DL = DebugLoc::getUnknown()) - : VPDef(SC), VPUser(Operands), DL(DL) {} + : VPDef(), VPUser(Operands), SubclassID(SC), DL(DL) {} ~VPRecipeBase() override = default; @@ -450,6 +505,9 @@ class LLVM_ABI_FOR_TEST VPRecipeBase /// \returns an iterator pointing to the element after the erased one iplist::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. @@ -485,9 +543,12 @@ 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 override final; + VPSlotTracker &SlotTracker) const; #endif protected: @@ -506,23 +567,20 @@ class LLVM_ABI_FOR_TEST VPRecipeBase }; // Helper macro to define common classof implementations for recipes. -#define VP_CLASSOF_IMPL(VPDefID) \ - static inline bool classof(const VPDef *D) { \ - return D->getVPDefID() == VPDefID; \ +#define VP_CLASSOF_IMPL(VPRecipeID) \ + static inline bool classof(const VPRecipeBase *R) { \ + return R->getVPRecipeID() == VPRecipeID; \ } \ static inline bool classof(const VPValue *V) { \ auto *R = V->getDefiningRecipe(); \ - return R && R->getVPDefID() == VPDefID; \ + return R && R->getVPRecipeID() == VPRecipeID; \ } \ static inline bool classof(const VPUser *U) { \ auto *R = dyn_cast(U); \ - return R && R->getVPDefID() == VPDefID; \ - } \ - static inline bool classof(const VPRecipeBase *R) { \ - return R->getVPDefID() == VPDefID; \ + return R && R->getVPRecipeID() == VPRecipeID; \ } \ static inline bool classof(const VPSingleDefRecipe *R) { \ - return R->getVPDefID() == VPDefID; \ + return R->getVPRecipeID() == VPRecipeID; \ } /// VPSingleDef is a base class for recipes for modeling a sequence of one or @@ -539,7 +597,7 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPRecipeValue { : VPRecipeBase(SC, Operands, DL), VPRecipeValue(this, UV) {} static inline bool classof(const VPRecipeBase *R) { - switch (R->getVPDefID()) { + switch (R->getVPRecipeID()) { case VPRecipeBase::VPDerivedIVSC: case VPRecipeBase::VPEVLBasedIVPHISC: case VPRecipeBase::VPExpandSCEVSC: @@ -580,7 +638,7 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPRecipeValue { // the recipes to be able to make widened loads VPSingleDefRecipes. return false; } - llvm_unreachable("Unhandled VPDefID"); + llvm_unreachable("Unhandled VPRecipeID"); } static inline bool classof(const VPUser *U) { @@ -978,17 +1036,17 @@ struct VPRecipeWithIRFlags : public VPSingleDefRecipe, public VPIRFlags { : VPSingleDefRecipe(SC, Operands, DL), VPIRFlags(Flags) {} static inline bool classof(const VPRecipeBase *R) { - 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; + 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; } static inline bool classof(const VPUser *U) { @@ -997,15 +1055,14 @@ struct VPRecipeWithIRFlags : public VPSingleDefRecipe, public VPIRFlags { } static inline bool classof(const VPValue *V) { - auto *R = dyn_cast_or_null(V->getDefiningRecipe()); + auto *R = V->getDefiningRecipe(); return R && classof(R); } VPRecipeWithIRFlags *clone() override = 0; - static inline bool classof(const VPSingleDefRecipe *U) { - auto *R = dyn_cast(U); - return R && classof(R); + static inline bool classof(const VPSingleDefRecipe *R) { + return classof(static_cast(R)); } void execute(VPTransformState &State) override = 0; @@ -1233,7 +1290,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(VPDef::VPInstructionSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPInstructionSC) VPInstruction *clone() override { auto *New = new VPInstruction(Opcode, operands(), *this, *this, @@ -1315,7 +1372,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 VPDef ID +/// directly determine the result type. Note that there is no separate recipe ID /// for VPInstructionWithType; it shares the same ID as VPInstruction and is /// distinguished purely by the opcode. class VPInstructionWithType : public VPInstruction { @@ -1485,7 +1542,8 @@ 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(VPDef::VPIRInstructionSC, ArrayRef()), I(I) {} + : VPRecipeBase(VPRecipeBase::VPIRInstructionSC, ArrayRef()), + I(I) {} public: ~VPIRInstruction() override = default; @@ -1494,7 +1552,7 @@ class VPIRInstruction : public VPRecipeBase { /// VPIRInstruction. LLVM_ABI_FOR_TEST static VPIRInstruction *create(Instruction &I); - VP_CLASSOF_IMPL(VPDef::VPIRInstructionSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPIRInstructionSC) VPIRInstruction *clone() override { auto *R = create(I); @@ -1581,7 +1639,7 @@ class LLVM_ABI_FOR_TEST VPWidenRecipe : public VPRecipeWithIRFlags, VPWidenRecipe(Instruction &I, ArrayRef Operands, const VPIRFlags &Flags = {}, const VPIRMetadata &Metadata = {}, DebugLoc DL = {}) - : VPRecipeWithIRFlags(VPDef::VPWidenSC, Operands, Flags, DL), + : VPRecipeWithIRFlags(VPRecipeBase::VPWidenSC, Operands, Flags, DL), VPIRMetadata(Metadata), Opcode(I.getOpcode()) { setUnderlyingValue(&I); } @@ -1593,7 +1651,7 @@ class LLVM_ABI_FOR_TEST VPWidenRecipe : public VPRecipeWithIRFlags, getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPWidenSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenSC) /// Produce a widened instruction using the opcode and operands of the recipe, /// processing State.VF elements. @@ -1634,7 +1692,7 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags, public VPIRMetadata { CastInst *CI = nullptr, const VPIRFlags &Flags = {}, const VPIRMetadata &Metadata = {}, DebugLoc DL = DebugLoc::getUnknown()) - : VPRecipeWithIRFlags(VPDef::VPWidenCastSC, Op, Flags, DL), + : VPRecipeWithIRFlags(VPRecipeBase::VPWidenCastSC, Op, Flags, DL), VPIRMetadata(Metadata), Opcode(Opcode), ResultTy(ResultTy) { assert(flagsValidForOpcode(Opcode) && "Set flags not supported for the provided opcode"); @@ -1649,7 +1707,7 @@ class VPWidenCastRecipe : public VPRecipeWithIRFlags, public VPIRMetadata { *this, *this, getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPWidenCastSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenCastSC) /// Produce widened copies of the cast. LLVM_ABI_FOR_TEST void execute(VPTransformState &State) override; @@ -1694,8 +1752,8 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata { const VPIRFlags &Flags = {}, const VPIRMetadata &MD = {}, DebugLoc DL = DebugLoc::getUnknown()) - : VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, Flags, - DL), + : VPRecipeWithIRFlags(VPRecipeBase::VPWidenIntrinsicSC, CallArguments, + Flags, DL), VPIRMetadata(MD), VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty), MayReadFromMemory(CI.mayReadFromMemory()), MayWriteToMemory(CI.mayWriteToMemory()), @@ -1708,8 +1766,8 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata { const VPIRFlags &Flags = {}, const VPIRMetadata &Metadata = {}, DebugLoc DL = DebugLoc::getUnknown()) - : VPRecipeWithIRFlags(VPDef::VPWidenIntrinsicSC, CallArguments, Flags, - DL), + : VPRecipeWithIRFlags(VPRecipeBase::VPWidenIntrinsicSC, CallArguments, + Flags, DL), VPIRMetadata(Metadata), VectorIntrinsicID(VectorIntrinsicID), ResultTy(Ty) { LLVMContext &Ctx = Ty->getContext(); @@ -1733,7 +1791,7 @@ class VPWidenIntrinsicRecipe : public VPRecipeWithIRFlags, public VPIRMetadata { *this, *this, getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPWidenIntrinsicSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenIntrinsicSC) /// Produce a widened version of the vector intrinsic. LLVM_ABI_FOR_TEST void execute(VPTransformState &State) override; @@ -1783,7 +1841,8 @@ class LLVM_ABI_FOR_TEST VPWidenCallRecipe : public VPRecipeWithIRFlags, ArrayRef CallArguments, const VPIRFlags &Flags = {}, const VPIRMetadata &Metadata = {}, DebugLoc DL = {}) - : VPRecipeWithIRFlags(VPDef::VPWidenCallSC, CallArguments, Flags, DL), + : VPRecipeWithIRFlags(VPRecipeBase::VPWidenCallSC, CallArguments, Flags, + DL), VPIRMetadata(Metadata), Variant(Variant) { setUnderlyingValue(UV); assert( @@ -1798,7 +1857,7 @@ class LLVM_ABI_FOR_TEST VPWidenCallRecipe : public VPRecipeWithIRFlags, *this, *this, getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPWidenCallSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenCallSC) /// Produce a widened version of the call instruction. void execute(VPTransformState &State) override; @@ -1834,7 +1893,8 @@ class VPHistogramRecipe : public VPRecipeBase { public: VPHistogramRecipe(unsigned Opcode, ArrayRef Operands, DebugLoc DL = DebugLoc::getUnknown()) - : VPRecipeBase(VPDef::VPHistogramSC, Operands, DL), Opcode(Opcode) {} + : VPRecipeBase(VPRecipeBase::VPHistogramSC, Operands, DL), + Opcode(Opcode) {} ~VPHistogramRecipe() override = default; @@ -1842,7 +1902,7 @@ class VPHistogramRecipe : public VPRecipeBase { return new VPHistogramRecipe(Opcode, operands(), getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPHistogramSC); + VP_CLASSOF_IMPL(VPRecipeBase::VPHistogramSC); /// Produce a vectorized histogram operation. void execute(VPTransformState &State) override; @@ -1883,7 +1943,7 @@ class LLVM_ABI_FOR_TEST VPWidenGEPRecipe : public VPRecipeWithIRFlags { VPWidenGEPRecipe(GetElementPtrInst *GEP, ArrayRef Operands, const VPIRFlags &Flags = {}, DebugLoc DL = DebugLoc::getUnknown()) - : VPRecipeWithIRFlags(VPDef::VPWidenGEPSC, Operands, Flags, DL), + : VPRecipeWithIRFlags(VPRecipeBase::VPWidenGEPSC, Operands, Flags, DL), SourceElementTy(GEP->getSourceElementType()) { setUnderlyingValue(GEP); SmallVector> Metadata; @@ -1899,7 +1959,7 @@ class LLVM_ABI_FOR_TEST VPWidenGEPRecipe : public VPRecipeWithIRFlags { operands(), *this, getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPWidenGEPSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenGEPSC) /// This recipe generates a GEP instruction. unsigned getOpcode() const { return Instruction::GetElementPtr; } @@ -1941,13 +2001,13 @@ class VPVectorEndPointerRecipe : public VPRecipeWithIRFlags, public: VPVectorEndPointerRecipe(VPValue *Ptr, VPValue *VF, Type *IndexedTy, int64_t Stride, GEPNoWrapFlags GEPFlags, DebugLoc DL) - : VPRecipeWithIRFlags(VPDef::VPVectorEndPointerSC, + : VPRecipeWithIRFlags(VPRecipeBase::VPVectorEndPointerSC, ArrayRef({Ptr, VF}), GEPFlags, DL), IndexedTy(IndexedTy), Stride(Stride) { assert(Stride < 0 && "Stride must be negative"); } - VP_CLASSOF_IMPL(VPDef::VPVectorEndPointerSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPVectorEndPointerSC) VPValue *getVFValue() { return getOperand(1); } const VPValue *getVFValue() const { return getOperand(1); } @@ -1998,10 +2058,10 @@ class VPVectorPointerRecipe : public VPRecipeWithIRFlags { public: VPVectorPointerRecipe(VPValue *Ptr, Type *SourceElementTy, GEPNoWrapFlags GEPFlags, DebugLoc DL) - : VPRecipeWithIRFlags(VPDef::VPVectorPointerSC, Ptr, GEPFlags, DL), + : VPRecipeWithIRFlags(VPRecipeBase::VPVectorPointerSC, Ptr, GEPFlags, DL), SourceElementTy(SourceElementTy) {} - VP_CLASSOF_IMPL(VPDef::VPVectorPointerSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPVectorPointerSC) VPValue *getOffset() { return getNumOperands() == 2 ? getOperand(1) : nullptr; @@ -2074,9 +2134,9 @@ class VPVectorPointerRecipe : public VPRecipeWithIRFlags { class LLVM_ABI_FOR_TEST VPHeaderPHIRecipe : public VPSingleDefRecipe, public VPPhiAccessors { protected: - VPHeaderPHIRecipe(unsigned char VPDefID, Instruction *UnderlyingInstr, + VPHeaderPHIRecipe(unsigned char VPRecipeID, Instruction *UnderlyingInstr, VPValue *Start, DebugLoc DL = DebugLoc::getUnknown()) - : VPSingleDefRecipe(VPDefID, ArrayRef({Start}), + : VPSingleDefRecipe(VPRecipeID, ArrayRef({Start}), UnderlyingInstr, DL) {} const VPRecipeBase *getAsRecipe() const override { return this; } @@ -2086,8 +2146,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->getVPDefID() >= VPDef::VPFirstHeaderPHISC && - R->getVPDefID() <= VPDef::VPLastHeaderPHISC; + return R->getVPRecipeID() >= VPRecipeBase::VPFirstHeaderPHISC && + R->getVPRecipeID() <= VPRecipeBase::VPLastHeaderPHISC; } static inline bool classof(const VPValue *V) { return isa(V->getDefiningRecipe()); @@ -2151,8 +2211,8 @@ class VPWidenInductionRecipe : public VPHeaderPHIRecipe { } static inline bool classof(const VPRecipeBase *R) { - return R->getVPDefID() == VPDef::VPWidenIntOrFpInductionSC || - R->getVPDefID() == VPDef::VPWidenPointerInductionSC; + return R->getVPRecipeID() == VPRecipeBase::VPWidenIntOrFpInductionSC || + R->getVPRecipeID() == VPRecipeBase::VPWidenPointerInductionSC; } static inline bool classof(const VPValue *V) { @@ -2228,8 +2288,8 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe, VPWidenIntOrFpInductionRecipe(PHINode *IV, VPIRValue *Start, VPValue *Step, VPValue *VF, const InductionDescriptor &IndDesc, const VPIRFlags &Flags, DebugLoc DL) - : VPWidenInductionRecipe(VPDef::VPWidenIntOrFpInductionSC, IV, Start, - Step, IndDesc, DL), + : VPWidenInductionRecipe(VPRecipeBase::VPWidenIntOrFpInductionSC, IV, + Start, Step, IndDesc, DL), VPIRFlags(Flags), Trunc(nullptr) { addOperand(VF); } @@ -2238,8 +2298,8 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe, VPValue *VF, const InductionDescriptor &IndDesc, TruncInst *Trunc, const VPIRFlags &Flags, DebugLoc DL) - : VPWidenInductionRecipe(VPDef::VPWidenIntOrFpInductionSC, IV, Start, - Step, IndDesc, DL), + : VPWidenInductionRecipe(VPRecipeBase::VPWidenIntOrFpInductionSC, IV, + Start, Step, IndDesc, DL), VPIRFlags(Flags), Trunc(Trunc) { addOperand(VF); SmallVector> Metadata; @@ -2257,7 +2317,7 @@ class VPWidenIntOrFpInductionRecipe : public VPWidenInductionRecipe, getInductionDescriptor(), Trunc, *this, getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPWidenIntOrFpInductionSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenIntOrFpInductionSC) void execute(VPTransformState &State) override { llvm_unreachable("cannot execute this recipe, should be expanded via " @@ -2316,8 +2376,8 @@ class VPWidenPointerInductionRecipe : public VPWidenInductionRecipe { VPWidenPointerInductionRecipe(PHINode *Phi, VPValue *Start, VPValue *Step, VPValue *NumUnrolledElems, const InductionDescriptor &IndDesc, DebugLoc DL) - : VPWidenInductionRecipe(VPDef::VPWidenPointerInductionSC, Phi, Start, - Step, IndDesc, DL) { + : VPWidenInductionRecipe(VPRecipeBase::VPWidenPointerInductionSC, Phi, + Start, Step, IndDesc, DL) { addOperand(NumUnrolledElems); } @@ -2329,7 +2389,7 @@ class VPWidenPointerInductionRecipe : public VPWidenInductionRecipe { getOperand(2), getInductionDescriptor(), getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPWidenPointerInductionSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenPointerInductionSC) /// Generate vector values for the pointer induction. void execute(VPTransformState &State) override { @@ -2363,7 +2423,8 @@ 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(VPDef::VPWidenPHISC, {}, Phi, DL), Name(Name.str()) { + : VPSingleDefRecipe(VPRecipeBase::VPWidenPHISC, {}, Phi, DL), + Name(Name.str()) { if (Start) addOperand(Start); } @@ -2378,7 +2439,7 @@ class LLVM_ABI_FOR_TEST VPWidenPHIRecipe : public VPSingleDefRecipe, ~VPWidenPHIRecipe() override = default; - VP_CLASSOF_IMPL(VPDef::VPWidenPHISC) + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenPHISC) /// Generate the phi/select nodes. void execute(VPTransformState &State) override; @@ -2403,11 +2464,12 @@ class LLVM_ABI_FOR_TEST VPWidenPHIRecipe : public VPSingleDefRecipe, struct VPFirstOrderRecurrencePHIRecipe : public VPHeaderPHIRecipe { VPFirstOrderRecurrencePHIRecipe(PHINode *Phi, VPValue &Start, VPValue &BackedgeValue) - : VPHeaderPHIRecipe(VPDef::VPFirstOrderRecurrencePHISC, Phi, &Start) { + : VPHeaderPHIRecipe(VPRecipeBase::VPFirstOrderRecurrencePHISC, Phi, + &Start) { addOperand(&BackedgeValue); } - VP_CLASSOF_IMPL(VPDef::VPFirstOrderRecurrencePHISC) + VP_CLASSOF_IMPL(VPRecipeBase::VPFirstOrderRecurrencePHISC) VPFirstOrderRecurrencePHIRecipe *clone() override { return new VPFirstOrderRecurrencePHIRecipe( @@ -2479,8 +2541,8 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe, VPReductionPHIRecipe(PHINode *Phi, RecurKind Kind, VPValue &Start, VPValue &BackedgeValue, ReductionStyle Style, bool HasUsesOutsideReductionChain = false) - : VPHeaderPHIRecipe(VPDef::VPReductionPHISC, Phi, &Start), Kind(Kind), - Style(Style), + : VPHeaderPHIRecipe(VPRecipeBase::VPReductionPHISC, Phi, &Start), + Kind(Kind), Style(Style), HasUsesOutsideReductionChain(HasUsesOutsideReductionChain) { addOperand(&BackedgeValue); } @@ -2494,7 +2556,7 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe, HasUsesOutsideReductionChain); } - VP_CLASSOF_IMPL(VPDef::VPReductionPHISC) + VP_CLASSOF_IMPL(VPRecipeBase::VPReductionPHISC) /// Generate the phi/select nodes. void execute(VPTransformState &State) override; @@ -2562,7 +2624,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 Operands, DebugLoc DL) - : VPSingleDefRecipe(VPDef::VPBlendSC, Operands, Phi, DL) { + : VPSingleDefRecipe(VPRecipeBase::VPBlendSC, Operands, Phi, DL) { assert(Operands.size() >= 2 && "Expected at least two operands!"); } @@ -2571,7 +2633,7 @@ class LLVM_ABI_FOR_TEST VPBlendRecipe : public VPSingleDefRecipe { operands(), getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPBlendSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPBlendSC) /// A normalized blend is one that has an odd number of operands, whereby the /// first operand does not have an associated mask. @@ -2674,8 +2736,8 @@ class LLVM_ABI_FOR_TEST VPInterleaveBase : public VPRecipeBase, VPInterleaveBase *clone() override = 0; static inline bool classof(const VPRecipeBase *R) { - return R->getVPDefID() == VPRecipeBase::VPInterleaveSC || - R->getVPDefID() == VPRecipeBase::VPInterleaveEVLSC; + return R->getVPRecipeID() == VPRecipeBase::VPInterleaveSC || + R->getVPRecipeID() == VPRecipeBase::VPInterleaveEVLSC; } static inline bool classof(const VPUser *U) { @@ -2735,8 +2797,8 @@ class LLVM_ABI_FOR_TEST VPInterleaveRecipe final : public VPInterleaveBase { VPInterleaveRecipe(const InterleaveGroup *IG, VPValue *Addr, ArrayRef StoredValues, VPValue *Mask, bool NeedsMaskForGaps, const VPIRMetadata &MD, DebugLoc DL) - : VPInterleaveBase(VPDef::VPInterleaveSC, IG, Addr, StoredValues, Mask, - NeedsMaskForGaps, MD, DL) {} + : VPInterleaveBase(VPRecipeBase::VPInterleaveSC, IG, Addr, StoredValues, + Mask, NeedsMaskForGaps, MD, DL) {} ~VPInterleaveRecipe() override = default; @@ -2746,7 +2808,7 @@ class LLVM_ABI_FOR_TEST VPInterleaveRecipe final : public VPInterleaveBase { needsMaskForGaps(), *this, getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPInterleaveSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPInterleaveSC) /// Generate the wide load or store, and shuffles. void execute(VPTransformState &State) override; @@ -2775,10 +2837,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(VPDef::VPInterleaveEVLSC, R.getInterleaveGroup(), - ArrayRef({R.getAddr(), &EVL}), - R.getStoredValues(), Mask, R.needsMaskForGaps(), R, - R.getDebugLoc()) { + : VPInterleaveBase( + VPRecipeBase::VPInterleaveEVLSC, R.getInterleaveGroup(), + ArrayRef({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 " @@ -2791,7 +2853,7 @@ class LLVM_ABI_FOR_TEST VPInterleaveEVLRecipe final : public VPInterleaveBase { llvm_unreachable("cloning not implemented yet"); } - VP_CLASSOF_IMPL(VPDef::VPInterleaveEVLSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPInterleaveEVLSC) /// The VPValue of the explicit vector length. VPValue *getEVL() const { return getOperand(1); } @@ -2849,14 +2911,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(VPDef::VPReductionSC, RdxKind, FMFs, I, + : VPReductionRecipe(VPRecipeBase::VPReductionSC, RdxKind, FMFs, I, ArrayRef({ChainOp, VecOp}), CondOp, Style, DL) {} VPReductionRecipe(const RecurKind RdxKind, FastMathFlags FMFs, VPValue *ChainOp, VPValue *VecOp, VPValue *CondOp, ReductionStyle Style, DebugLoc DL = DebugLoc::getUnknown()) - : VPReductionRecipe(VPDef::VPReductionSC, RdxKind, FMFs, nullptr, + : VPReductionRecipe(VPRecipeBase::VPReductionSC, RdxKind, FMFs, nullptr, ArrayRef({ChainOp, VecOp}), CondOp, Style, DL) {} @@ -2869,8 +2931,8 @@ class LLVM_ABI_FOR_TEST VPReductionRecipe : public VPRecipeWithIRFlags { } static inline bool classof(const VPRecipeBase *R) { - return R->getVPDefID() == VPRecipeBase::VPReductionSC || - R->getVPDefID() == VPRecipeBase::VPReductionEVLSC; + return R->getVPRecipeID() == VPRecipeBase::VPReductionSC || + R->getVPRecipeID() == VPRecipeBase::VPReductionEVLSC; } static inline bool classof(const VPUser *U) { @@ -2939,7 +3001,7 @@ class LLVM_ABI_FOR_TEST VPReductionEVLRecipe : public VPReductionRecipe { VPReductionEVLRecipe(VPReductionRecipe &R, VPValue &EVL, VPValue *CondOp, DebugLoc DL = DebugLoc::getUnknown()) : VPReductionRecipe( - VPDef::VPReductionEVLSC, R.getRecurrenceKind(), + VPRecipeBase::VPReductionEVLSC, R.getRecurrenceKind(), R.getFastMathFlags(), cast_or_null(R.getUnderlyingValue()), ArrayRef({R.getChainOp(), R.getVecOp(), &EVL}), CondOp, @@ -2951,7 +3013,7 @@ class LLVM_ABI_FOR_TEST VPReductionEVLRecipe : public VPReductionRecipe { llvm_unreachable("cloning not implemented yet"); } - VP_CLASSOF_IMPL(VPDef::VPReductionEVLSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPReductionEVLSC) /// Generate the reduction in the loop void execute(VPTransformState &State) override; @@ -2991,7 +3053,7 @@ class LLVM_ABI_FOR_TEST VPReplicateRecipe : public VPRecipeWithIRFlags, bool IsSingleScalar, VPValue *Mask = nullptr, const VPIRFlags &Flags = {}, VPIRMetadata Metadata = {}, DebugLoc DL = DebugLoc::getUnknown()) - : VPRecipeWithIRFlags(VPDef::VPReplicateSC, Operands, Flags, DL), + : VPRecipeWithIRFlags(VPRecipeBase::VPReplicateSC, Operands, Flags, DL), VPIRMetadata(Metadata), IsSingleScalar(IsSingleScalar), IsPredicated(Mask) { setUnderlyingValue(I); @@ -3009,7 +3071,7 @@ class LLVM_ABI_FOR_TEST VPReplicateRecipe : public VPRecipeWithIRFlags, return Copy; } - VP_CLASSOF_IMPL(VPDef::VPReplicateSC) + VP_CLASSOF_IMPL(VPRecipeBase::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 @@ -3063,13 +3125,13 @@ class LLVM_ABI_FOR_TEST VPReplicateRecipe : public VPRecipeWithIRFlags, class LLVM_ABI_FOR_TEST VPBranchOnMaskRecipe : public VPRecipeBase { public: VPBranchOnMaskRecipe(VPValue *BlockInMask, DebugLoc DL) - : VPRecipeBase(VPDef::VPBranchOnMaskSC, {BlockInMask}, DL) {} + : VPRecipeBase(VPRecipeBase::VPBranchOnMaskSC, {BlockInMask}, DL) {} VPBranchOnMaskRecipe *clone() override { return new VPBranchOnMaskRecipe(getOperand(0), getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPBranchOnMaskSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPBranchOnMaskSC) /// Generate the extraction of the appropriate bit from the block mask and the /// conditional branch. @@ -3178,7 +3240,7 @@ class VPExpressionRecipe : public VPSingleDefRecipe { delete T; } - VP_CLASSOF_IMPL(VPDef::VPExpressionSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPExpressionSC) VPExpressionRecipe *clone() override { assert(!ExpressionRecipes.empty() && "empty expressions should be removed"); @@ -3252,14 +3314,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(VPDef::VPPredInstPHISC, PredV, DL) {} + : VPSingleDefRecipe(VPRecipeBase::VPPredInstPHISC, PredV, DL) {} ~VPPredInstPHIRecipe() override = default; VPPredInstPHIRecipe *clone() override { return new VPPredInstPHIRecipe(getOperand(0), getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPPredInstPHISC) + VP_CLASSOF_IMPL(VPRecipeBase::VPPredInstPHISC) /// Generates phi nodes for live-outs (from a replicate region) as needed to /// retain SSA form. @@ -3332,10 +3394,10 @@ class LLVM_ABI_FOR_TEST VPWidenMemoryRecipe : public VPRecipeBase, } static inline bool classof(const VPRecipeBase *R) { - return R->getVPDefID() == VPRecipeBase::VPWidenLoadSC || - R->getVPDefID() == VPRecipeBase::VPWidenStoreSC || - R->getVPDefID() == VPRecipeBase::VPWidenLoadEVLSC || - R->getVPDefID() == VPRecipeBase::VPWidenStoreEVLSC; + return R->getVPRecipeID() == VPRecipeBase::VPWidenLoadSC || + R->getVPRecipeID() == VPRecipeBase::VPWidenStoreSC || + R->getVPRecipeID() == VPRecipeBase::VPWidenLoadEVLSC || + R->getVPRecipeID() == VPRecipeBase::VPWidenStoreEVLSC; } static inline bool classof(const VPUser *U) { @@ -3385,8 +3447,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(VPDef::VPWidenLoadSC, Load, {Addr}, Consecutive, - Reverse, Metadata, DL), + : VPWidenMemoryRecipe(VPRecipeBase::VPWidenLoadSC, Load, {Addr}, + Consecutive, Reverse, Metadata, DL), VPRecipeValue(this, &Load) { setMask(Mask); } @@ -3397,7 +3459,7 @@ struct LLVM_ABI_FOR_TEST VPWidenLoadRecipe final : public VPWidenMemoryRecipe, getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPWidenLoadSC); + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenLoadSC); /// Generate a wide load or gather. void execute(VPTransformState &State) override; @@ -3426,14 +3488,14 @@ struct VPWidenLoadEVLRecipe final : public VPWidenMemoryRecipe, public VPRecipeValue { VPWidenLoadEVLRecipe(VPWidenLoadRecipe &L, VPValue *Addr, VPValue &EVL, VPValue *Mask) - : VPWidenMemoryRecipe(VPDef::VPWidenLoadEVLSC, L.getIngredient(), + : VPWidenMemoryRecipe(VPRecipeBase::VPWidenLoadEVLSC, L.getIngredient(), {Addr, &EVL}, L.isConsecutive(), L.isReverse(), L, L.getDebugLoc()), VPRecipeValue(this, &getIngredient()) { setMask(Mask); } - VP_CLASSOF_IMPL(VPDef::VPWidenLoadEVLSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenLoadEVLSC) /// Return the EVL operand. VPValue *getEVL() const { return getOperand(1); } @@ -3468,8 +3530,9 @@ 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(VPDef::VPWidenStoreSC, Store, {Addr, StoredVal}, - Consecutive, Reverse, Metadata, DL) { + : VPWidenMemoryRecipe(VPRecipeBase::VPWidenStoreSC, Store, + {Addr, StoredVal}, Consecutive, Reverse, Metadata, + DL) { setMask(Mask); } @@ -3479,7 +3542,7 @@ struct LLVM_ABI_FOR_TEST VPWidenStoreRecipe final : public VPWidenMemoryRecipe { Reverse, *this, getDebugLoc()); } - VP_CLASSOF_IMPL(VPDef::VPWidenStoreSC); + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenStoreSC); /// Return the value stored by this recipe. VPValue *getStoredValue() const { return getOperand(1); } @@ -3510,13 +3573,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(VPDef::VPWidenStoreEVLSC, S.getIngredient(), + : VPWidenMemoryRecipe(VPRecipeBase::VPWidenStoreEVLSC, S.getIngredient(), {Addr, StoredVal, &EVL}, S.isConsecutive(), S.isReverse(), S, S.getDebugLoc()) { setMask(Mask); } - VP_CLASSOF_IMPL(VPDef::VPWidenStoreEVLSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenStoreEVLSC) /// Return the address accessed by this recipe. VPValue *getStoredValue() const { return getOperand(1); } @@ -3559,13 +3622,13 @@ class VPExpandSCEVRecipe : public VPSingleDefRecipe { public: VPExpandSCEVRecipe(const SCEV *Expr) - : VPSingleDefRecipe(VPDef::VPExpandSCEVSC, {}), Expr(Expr) {} + : VPSingleDefRecipe(VPRecipeBase::VPExpandSCEVSC, {}), Expr(Expr) {} ~VPExpandSCEVRecipe() override = default; VPExpandSCEVRecipe *clone() override { return new VPExpandSCEVRecipe(Expr); } - VP_CLASSOF_IMPL(VPDef::VPExpandSCEVSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPExpandSCEVSC) void execute(VPTransformState &State) override { llvm_unreachable("SCEV expressions must be expanded before final execute"); @@ -3595,7 +3658,8 @@ class VPExpandSCEVRecipe : public VPSingleDefRecipe { class VPCanonicalIVPHIRecipe : public VPHeaderPHIRecipe { public: VPCanonicalIVPHIRecipe(VPIRValue *StartV, DebugLoc DL) - : VPHeaderPHIRecipe(VPDef::VPCanonicalIVPHISC, nullptr, StartV, DL) {} + : VPHeaderPHIRecipe(VPRecipeBase::VPCanonicalIVPHISC, nullptr, StartV, + DL) {} ~VPCanonicalIVPHIRecipe() override = default; @@ -3605,7 +3669,7 @@ class VPCanonicalIVPHIRecipe : public VPHeaderPHIRecipe { return R; } - VP_CLASSOF_IMPL(VPDef::VPCanonicalIVPHISC) + VP_CLASSOF_IMPL(VPRecipeBase::VPCanonicalIVPHISC) void execute(VPTransformState &State) override { llvm_unreachable("cannot execute this recipe, should be replaced by a " @@ -3652,8 +3716,8 @@ class VPCanonicalIVPHIRecipe : public VPHeaderPHIRecipe { class VPActiveLaneMaskPHIRecipe : public VPHeaderPHIRecipe { public: VPActiveLaneMaskPHIRecipe(VPValue *StartMask, DebugLoc DL) - : VPHeaderPHIRecipe(VPDef::VPActiveLaneMaskPHISC, nullptr, StartMask, - DL) {} + : VPHeaderPHIRecipe(VPRecipeBase::VPActiveLaneMaskPHISC, nullptr, + StartMask, DL) {} ~VPActiveLaneMaskPHIRecipe() override = default; @@ -3664,7 +3728,7 @@ class VPActiveLaneMaskPHIRecipe : public VPHeaderPHIRecipe { return R; } - VP_CLASSOF_IMPL(VPDef::VPActiveLaneMaskPHISC) + VP_CLASSOF_IMPL(VPRecipeBase::VPActiveLaneMaskPHISC) /// Generate the active lane mask phi of the vector loop. void execute(VPTransformState &State) override; @@ -3684,7 +3748,8 @@ class VPActiveLaneMaskPHIRecipe : public VPHeaderPHIRecipe { class VPEVLBasedIVPHIRecipe : public VPHeaderPHIRecipe { public: VPEVLBasedIVPHIRecipe(VPValue *StartIV, DebugLoc DL) - : VPHeaderPHIRecipe(VPDef::VPEVLBasedIVPHISC, nullptr, StartIV, DL) {} + : VPHeaderPHIRecipe(VPRecipeBase::VPEVLBasedIVPHISC, nullptr, StartIV, + DL) {} ~VPEVLBasedIVPHIRecipe() override = default; @@ -3692,7 +3757,7 @@ class VPEVLBasedIVPHIRecipe : public VPHeaderPHIRecipe { llvm_unreachable("cloning not implemented yet"); } - VP_CLASSOF_IMPL(VPDef::VPEVLBasedIVPHISC) + VP_CLASSOF_IMPL(VPRecipeBase::VPEVLBasedIVPHISC) void execute(VPTransformState &State) override { llvm_unreachable("cannot execute this recipe, should be replaced by a " @@ -3726,7 +3791,7 @@ class VPWidenCanonicalIVRecipe : public VPSingleDefRecipe, public VPUnrollPartAccessor<1> { public: VPWidenCanonicalIVRecipe(VPCanonicalIVPHIRecipe *CanonicalIV) - : VPSingleDefRecipe(VPDef::VPWidenCanonicalIVSC, {CanonicalIV}) {} + : VPSingleDefRecipe(VPRecipeBase::VPWidenCanonicalIVSC, {CanonicalIV}) {} ~VPWidenCanonicalIVRecipe() override = default; @@ -3735,7 +3800,7 @@ class VPWidenCanonicalIVRecipe : public VPSingleDefRecipe, cast(getOperand(0))); } - VP_CLASSOF_IMPL(VPDef::VPWidenCanonicalIVSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPWidenCanonicalIVSC) /// Generate a canonical vector induction variable of the vector loop, with /// start = { for 0 <= Part < UF}, and @@ -3782,8 +3847,8 @@ class VPDerivedIVRecipe : public VPSingleDefRecipe { VPDerivedIVRecipe(InductionDescriptor::InductionKind Kind, const FPMathOperator *FPBinOp, VPIRValue *Start, VPValue *IV, VPValue *Step, const Twine &Name = "") - : VPSingleDefRecipe(VPDef::VPDerivedIVSC, {Start, IV, Step}), Kind(Kind), - FPBinOp(FPBinOp), Name(Name.str()) {} + : VPSingleDefRecipe(VPRecipeBase::VPDerivedIVSC, {Start, IV, Step}), + Kind(Kind), FPBinOp(FPBinOp), Name(Name.str()) {} ~VPDerivedIVRecipe() override = default; @@ -3792,7 +3857,7 @@ class VPDerivedIVRecipe : public VPSingleDefRecipe { getStepValue()); } - VP_CLASSOF_IMPL(VPDef::VPDerivedIVSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPDerivedIVSC) /// Generate the transformed value of the induction at offset StartValue (1. /// operand) + IV (2. operand) * StepValue (3, operand). @@ -3835,7 +3900,7 @@ class LLVM_ABI_FOR_TEST VPScalarIVStepsRecipe : public VPRecipeWithIRFlags, VPScalarIVStepsRecipe(VPValue *IV, VPValue *Step, VPValue *VF, Instruction::BinaryOps Opcode, FastMathFlags FMFs, DebugLoc DL) - : VPRecipeWithIRFlags(VPDef::VPScalarIVStepsSC, + : VPRecipeWithIRFlags(VPRecipeBase::VPScalarIVStepsSC, ArrayRef({IV, Step, VF}), FMFs, DL), InductionOpcode(Opcode) {} @@ -3862,7 +3927,7 @@ class LLVM_ABI_FOR_TEST VPScalarIVStepsRecipe : public VPRecipeWithIRFlags, /// this is only accurate after the VPlan has been unrolled. bool isPart0() const { return getUnrollPart(*this) == 0; } - VP_CLASSOF_IMPL(VPDef::VPScalarIVStepsSC) + VP_CLASSOF_IMPL(VPRecipeBase::VPScalarIVStepsSC) /// Generate the scalarized versions of the phi node as needed by their users. void execute(VPTransformState &State) override; @@ -3909,12 +3974,12 @@ struct CastInfoVPPhiAccessors : public CastIsPossible { /// doCast is used by cast<>. static inline VPPhiAccessors *doCast(SrcTy R) { return const_cast([R]() -> const VPPhiAccessors * { - switch (R->getVPDefID()) { - case VPDef::VPInstructionSC: + switch (R->getVPRecipeID()) { + case VPRecipeBase::VPInstructionSC: return cast(R); - case VPDef::VPIRInstructionSC: + case VPRecipeBase::VPIRInstructionSC: return cast(R); - case VPDef::VPWidenPHISC: + case VPRecipeBase::VPWidenPHISC: return cast(R); default: return cast(R); @@ -3941,26 +4006,26 @@ struct CastInfo namespace detail { template static inline auto castToVPIRMetadata(RecipeBasePtrTy R) -> DstTy { - switch (R->getVPDefID()) { - case VPDef::VPInstructionSC: + switch (R->getVPRecipeID()) { + case VPRecipeBase::VPInstructionSC: return cast(R); - case VPDef::VPWidenSC: + case VPRecipeBase::VPWidenSC: return cast(R); - case VPDef::VPWidenCastSC: + case VPRecipeBase::VPWidenCastSC: return cast(R); - case VPDef::VPWidenIntrinsicSC: + case VPRecipeBase::VPWidenIntrinsicSC: return cast(R); - case VPDef::VPWidenCallSC: + case VPRecipeBase::VPWidenCallSC: return cast(R); - case VPDef::VPReplicateSC: + case VPRecipeBase::VPReplicateSC: return cast(R); - case VPDef::VPInterleaveSC: - case VPDef::VPInterleaveEVLSC: + case VPRecipeBase::VPInterleaveSC: + case VPRecipeBase::VPInterleaveEVLSC: return cast(R); - case VPDef::VPWidenLoadSC: - case VPDef::VPWidenLoadEVLSC: - case VPDef::VPWidenStoreSC: - case VPDef::VPWidenStoreEVLSC: + case VPRecipeBase::VPWidenLoadSC: + case VPRecipeBase::VPWidenLoadEVLSC: + case VPRecipeBase::VPWidenStoreSC: + case VPRecipeBase::VPWidenStoreEVLSC: return cast(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 0c6100c04f785..ea3434d0e45a2 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp @@ -48,7 +48,7 @@ using VectorParts = SmallVector; #define DEBUG_TYPE LV_NAME bool VPRecipeBase::mayWriteToMemory() const { - switch (getVPDefID()) { + switch (getVPRecipeID()) { case VPExpressionSC: return cast(this)->mayReadOrWriteMemory(); case VPInstructionSC: { @@ -107,7 +107,7 @@ bool VPRecipeBase::mayWriteToMemory() const { } bool VPRecipeBase::mayReadFromMemory() const { - switch (getVPDefID()) { + switch (getVPRecipeID()) { case VPExpressionSC: return cast(this)->mayReadOrWriteMemory(); case VPInstructionSC: @@ -157,7 +157,7 @@ bool VPRecipeBase::mayReadFromMemory() const { } bool VPRecipeBase::mayHaveSideEffects() const { - switch (getVPDefID()) { + switch (getVPRecipeID()) { case VPExpressionSC: return cast(this)->mayHaveSideEffects(); case VPDerivedIVSC: @@ -302,7 +302,7 @@ InstructionCost VPRecipeBase::computeCost(ElementCount VF, } bool VPRecipeBase::isPhi() const { - return (getVPDefID() >= VPFirstPHISC && getVPDefID() <= VPLastPHISC) || + return (getVPRecipeID() >= VPFirstPHISC && getVPRecipeID() <= VPLastPHISC) || isa(this); } @@ -378,7 +378,7 @@ FastMathFlags VPIRFlags::getFastMathFlags() const { } #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) -void VPSingleDefRecipe::dump() const { VPDef::dump(); } +void VPSingleDefRecipe::dump() const { VPRecipeBase::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 Operands, const VPIRFlags &Flags, const VPIRMetadata &MD, DebugLoc DL, const Twine &Name) - : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, Flags, DL), + : VPRecipeWithIRFlags(VPRecipeBase::VPInstructionSC, Operands, Flags, DL), VPIRMetadata(MD), Opcode(Opcode), Name(Name.str()) { assert(flagsValidForOpcode(getOpcode()) && "Set flags not supported for the provided opcode"); @@ -2864,7 +2864,7 @@ InstructionCost VPReductionRecipe::computeCost(ElementCount VF, VPExpressionRecipe::VPExpressionRecipe( ExpressionTypes ExpressionType, ArrayRef ExpressionRecipes) - : VPSingleDefRecipe(VPDef::VPExpressionSC, {}, {}), + : VPSingleDefRecipe(VPRecipeBase::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 bfef277070db7..8e949bd741dd9 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp @@ -1116,9 +1116,9 @@ getOpcodeOrIntrinsicID(const VPSingleDefRecipe *R) { .Case([](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. + // after the last IR Instruction opcode), based on the VPRecipeID. return std::make_pair(false, - VPInstruction::OpsEnd + 1 + I->getVPDefID()); + VPInstruction::OpsEnd + 1 + I->getVPRecipeID()); }) .Default([](auto *) { return std::nullopt; }); } @@ -2440,7 +2440,7 @@ struct VPCSEDenseMapInfo : public DenseMapInfo { const VPlan *Plan = Def->getParent()->getPlan(); VPTypeAnalysis TypeInfo(*Plan); hash_code Result = hash_combine( - Def->getVPDefID(), getOpcodeOrIntrinsicID(Def), + Def->getVPRecipeID(), getOpcodeOrIntrinsicID(Def), getGEPSourceElementType(Def), TypeInfo.inferScalarType(Def), vputils::isSingleScalar(Def), hash_combine_range(Def->operands())); if (auto *RFlags = dyn_cast(Def)) @@ -2453,7 +2453,7 @@ struct VPCSEDenseMapInfo : public DenseMapInfo { static bool isEqual(const VPSingleDefRecipe *L, const VPSingleDefRecipe *R) { if (isSentinel(L) || isSentinel(R)) return L == R; - if (L->getVPDefID() != R->getVPDefID() || + if (L->getVPRecipeID() != R->getVPRecipeID() || 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 cae0633dbb185..e30c33a770327 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanValue.h +++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h @@ -33,7 +33,6 @@ class raw_ostream; class Type; class Value; class VPDef; -struct VPDoubleValueDef; class VPSlotTracker; class VPUser; class VPRecipeBase; @@ -43,8 +42,6 @@ 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; @@ -211,11 +208,17 @@ struct VPSymbolicValue : public VPValue { class VPRecipeValue : public VPValue { friend class VPValue; friend class VPDef; - /// Pointer to the VPDef that defines this VPValue. - VPDef *Def; + + /// Pointer to the VPRecipeBase that defines this VPValue. + VPRecipeBase *Def; + +#if !defined(NDEBUG) + /// Returns true if this VPRecipeValue is defined by \p D. + bool isDefinedBy(const VPDef *D) const; +#endif public: - VPRecipeValue(VPDef *Def, Value *UV = nullptr); + VPRecipeValue(VPRecipeBase *Def, Value *UV = nullptr); virtual ~VPRecipeValue(); @@ -330,18 +333,14 @@ 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 DefinedValues; /// Add \p V as a defined value by this VPDef. void addDefinedValue(VPRecipeValue *V) { - assert(V->Def == this && + assert(V->isDefinedBy(this) && "can only add VPValue already linked with this VPDef"); DefinedValues.push_back(V); } @@ -349,7 +348,8 @@ 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->Def == this && "can only remove VPValue linked with this VPDef"); + assert(V->isDefinedBy(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); @@ -357,63 +357,11 @@ class VPDef { } 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, - VPWidenSelectSC, - 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) {} + VPDef() {} virtual ~VPDef() { for (VPRecipeValue *D : to_vector(DefinedValues)) { - assert(D->Def == this && + assert(D->isDefinedBy(this) && "all defined VPValues should point to the containing VPDef"); assert(D->getNumUsers() == 0 && "all defined VPValues should have no more users"); @@ -451,20 +399,6 @@ 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 b49c57a1332cf..9b1e7c0af7c8c 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, CastVPWidenCallRecipeToVPUserAndVPDef) { +TEST_F(VPRecipeTest, CastVPWidenCallRecipeToVPUserAndVPRecipeBase) { VPlan &Plan = getPlan(); IntegerType *Int32 = IntegerType::get(C, 32); FunctionType *FTy = FunctionType::get(Int32, false); @@ -1056,7 +1056,6 @@ TEST_F(VPRecipeTest, CastVPWidenGEPRecipeToVPUserAndVPDef) { checkVPRecipeCastImpl(&Recipe); VPValue *VPV = &Recipe; - EXPECT_TRUE(isa(VPV->getDefiningRecipe())); EXPECT_EQ(&Recipe, VPV->getDefiningRecipe()); delete GEP; @@ -1141,7 +1140,7 @@ TEST_F(VPRecipeTest, CastVPBranchOnMaskRecipeToVPUser) { checkVPRecipeCastImpl(&Recipe); } -TEST_F(VPRecipeTest, CastVPWidenMemoryRecipeToVPUserAndVPDef) { +TEST_F(VPRecipeTest, CastVPWidenMemoryRecipeToVPUserAndVPRecipeBase) { VPlan &Plan = getPlan(); IntegerType *Int32 = IntegerType::get(C, 32); PointerType *Int32Ptr = PointerType::get(C, 0); @@ -1154,7 +1153,6 @@ TEST_F(VPRecipeTest, CastVPWidenMemoryRecipeToVPUserAndVPDef) { checkVPRecipeCastImpl(&Recipe); VPValue *VPV = Recipe.getVPSingleValue(); - EXPECT_TRUE(isa(VPV->getDefiningRecipe())); EXPECT_EQ(&Recipe, VPV->getDefiningRecipe()); delete Load; @@ -1432,7 +1430,7 @@ TEST_F(VPRecipeTest, dumpRecipeInPlan) { }, testing::ExitedWithCode(0), "WIDEN ir<%a> = add ir<1>, ir<2>"); - VPDef *Def = WidenR; + VPRecipeBase *Def = WidenR; EXPECT_EXIT( { Def->dump(); @@ -1455,15 +1453,6 @@ 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; @@ -1511,15 +1500,6 @@ 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. { @@ -1542,15 +1522,6 @@ 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; } @@ -1587,15 +1558,6 @@ TEST_F(VPRecipeTest, dumpRecipeUnnamedVPValuesNotInPlanOrBlock) { exit(0); }, testing::ExitedWithCode(0), "EMIT = add ir<1>, ir<%a>"); - - // Test VPDef::dump(). - VPDef *D = I1; - EXPECT_EXIT( - { - D->dump(); - exit(0); - }, - testing::ExitedWithCode(0), "EMIT = add ir<1>, ir<%a>"); } // Check printing I2. { @@ -1618,15 +1580,6 @@ TEST_F(VPRecipeTest, dumpRecipeUnnamedVPValuesNotInPlanOrBlock) { exit(0); }, testing::ExitedWithCode(0), "EMIT = mul , "); - - // Test VPDef::dump(). - VPDef *D = I2; - EXPECT_EXIT( - { - D->dump(); - exit(0); - }, - testing::ExitedWithCode(0), "EMIT = mul , "); } delete I2; @@ -1683,7 +1636,7 @@ TEST(VPDoubleValueDefTest, traverseUseLists) { // Check that the def-use chains of a multi-def can be traversed in both // directions. - // Create a new VPDef which defines 2 values and has 2 operands. + // Create a new VPRecipeBase which defines 2 values and has 2 operands. VPInstruction Op0(VPInstruction::StepVector, {}); VPInstruction Op1(VPInstruction::VScale, {}); VPDoubleValueDef DoubleValueDef({&Op0, &Op1}); @@ -1694,7 +1647,7 @@ TEST(VPDoubleValueDefTest, traverseUseLists) { VPInstruction I2(Instruction::Freeze, {DoubleValueDef.getVPValue(0)}); VPInstruction I3(Instruction::Freeze, {DoubleValueDef.getVPValue(1)}); - // Check operands of the VPDef (traversing upwards). + // Check operands of the VPRecipeBase (traversing upwards). SmallVector DoubleOperands(DoubleValueDef.op_begin(), DoubleValueDef.op_end()); EXPECT_EQ(2u, DoubleOperands.size()); @@ -1716,7 +1669,7 @@ TEST(VPDoubleValueDefTest, traverseUseLists) { EXPECT_EQ(&I1, DoubleValueDefV1Users[0]); EXPECT_EQ(&I3, DoubleValueDefV1Users[1]); - // Now check that we can get the right VPDef for each defined value. + // Now check that we can get the right VPRecipeBase 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());