diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -739,9 +739,7 @@ bool mayHaveSideEffects() const; /// Returns true for PHI-like recipes. - bool isPhi() const { - return getVPDefID() >= VPFirstPHISC && getVPDefID() <= VPLastPHISC; - } + virtual bool isPhi() const { return false; } /// Returns true if the recipe may read from memory. bool mayReadFromMemory() const; @@ -1094,6 +1092,8 @@ /// Returns true if a vector phi needs to be created for the induction. bool needsVectorIV() const { return NeedsVectorIV; } + + bool isPhi() const override { return true; } }; /// A pure virtual base class for all recipes modeling header phis, including @@ -1134,12 +1134,12 @@ /// Method to support type inquiry through isa, cast, and dyn_cast. static inline bool classof(const VPRecipeBase *B) { return B->getVPDefID() >= VPDef::VPFirstHeaderPHISC && - B->getVPDefID() <= VPDef::VPLastPHISC; + B->getVPDefID() <= VPDef::VPLastHeaderPHISC; } static inline bool classof(const VPValue *V) { auto *B = V->getDefiningRecipe(); return B && B->getVPDefID() >= VPRecipeBase::VPFirstHeaderPHISC && - B->getVPDefID() <= VPRecipeBase::VPLastPHISC; + B->getVPDefID() <= VPRecipeBase::VPLastHeaderPHISC; } /// Generate the phi nodes. @@ -1172,6 +1172,8 @@ VPRecipeBase &getBackedgeRecipe() { return *getBackedgeValue()->getDefiningRecipe(); } + + bool isPhi() const override { return true; } }; class VPWidenPointerInductionRecipe : public VPHeaderPHIRecipe { @@ -1374,6 +1376,8 @@ return all_of(users(), [this](VPUser *U) { return U->onlyFirstLaneUsed(this); }); } + + bool isPhi() const override { return true; } }; /// VPInterleaveRecipe is a recipe for transforming an interleave group of load @@ -1634,6 +1638,8 @@ "Op must be an operand of the recipe"); return true; } + + bool isPhi() const override { return true; } }; /// A Recipe for widening load/store operations. diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h --- a/llvm/lib/Transforms/Vectorize/VPlanValue.h +++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h @@ -346,21 +346,20 @@ VPWidenMemoryInstructionSC, VPWidenSC, VPWidenSelectSC, - - // Phi-like recipes. Need to be kept together. VPBlendSC, VPPredInstPHISC, - // Header-phi recipes. Need to be kept together. + VPWidenIntOrFpInductionSC, + // START: SubclassID for recipes that inherit VPHeaderPHIRecipe. + // VPHeaderPHIRecipe need to be kept together. VPCanonicalIVPHISC, VPActiveLaneMaskPHISC, VPFirstOrderRecurrencePHISC, VPWidenPHISC, - VPWidenIntOrFpInductionSC, VPWidenPointerInductionSC, VPReductionPHISC, - VPFirstPHISC = VPBlendSC, + // END: SubclassID for recipes that inherit VPHeaderPHIRecipe VPFirstHeaderPHISC = VPCanonicalIVPHISC, - VPLastPHISC = VPReductionPHISC, + VPLastHeaderPHISC = VPReductionPHISC, }; VPDef(const unsigned char SC) : SubclassID(SC) {}