From af98b875e89e3b8071f4c617916b5b9590cc30cc Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Sun, 28 Aug 2022 15:53:35 +0100 Subject: [PATCH] [VPlan] Use range check in VPHeaderPHIRecipe::classof (NFC). This addresses a suggestion to simplify the check from D131989. This also makes it easier to ensure that VPHeaderPHIRecipe::classof checks for all header phi ids. --- llvm/lib/Transforms/Vectorize/VPlan.h | 18 ++++-------------- llvm/lib/Transforms/Vectorize/VPlanValue.h | 9 +++++++-- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h index eab1223..533ad29 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.h +++ b/llvm/lib/Transforms/Vectorize/VPlan.h @@ -1134,22 +1134,12 @@ public: /// Method to support type inquiry through isa, cast, and dyn_cast. static inline bool classof(const VPRecipeBase *B) { - return B->getVPDefID() == VPRecipeBase::VPCanonicalIVPHISC || - B->getVPDefID() == VPRecipeBase::VPActiveLaneMaskPHISC || - B->getVPDefID() == VPRecipeBase::VPFirstOrderRecurrencePHISC || - B->getVPDefID() == VPRecipeBase::VPReductionPHISC || - B->getVPDefID() == VPRecipeBase::VPWidenIntOrFpInductionSC || - B->getVPDefID() == VPRecipeBase::VPWidenPointerInductionSC || - B->getVPDefID() == VPRecipeBase::VPWidenPHISC; + return B->getVPDefID() >= VPRecipeBase::VPFirstHeaderPHISC && + B->getVPDefID() <= VPRecipeBase::VPLastPHISC; } static inline bool classof(const VPValue *V) { - return V->getVPValueID() == VPValue::VPVCanonicalIVPHISC || - V->getVPValueID() == VPValue::VPVActiveLaneMaskPHISC || - V->getVPValueID() == VPValue::VPVFirstOrderRecurrencePHISC || - V->getVPValueID() == VPValue::VPVReductionPHISC || - V->getVPValueID() == VPValue::VPVWidenIntOrFpInductionSC || - V->getVPValueID() == VPValue::VPVWidenPointerInductionSC || - V->getVPValueID() == VPValue::VPVWidenPHISC; + return V->getVPValueID() >= VPValue::VPVFirstHeaderPHISC && + V->getVPValueID() <= VPValue::VPVLastPHISC; } /// Generate the phi nodes. diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h index c99fae1..3aac5dc 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanValue.h +++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h @@ -102,14 +102,17 @@ public: // Phi-like VPValues. Need to be kept together. VPVBlendSC, + VPVPredInstPHI, + // Header-phi recipes. Need to be kept together. VPVCanonicalIVPHISC, VPVActiveLaneMaskPHISC, VPVFirstOrderRecurrencePHISC, VPVWidenPHISC, VPVWidenIntOrFpInductionSC, VPVWidenPointerInductionSC, - VPVPredInstPHI, VPVReductionPHISC, + VPVFirstHeaderPHISC = VPVCanonicalIVPHISC, + VPVLastPHISC = VPVReductionPHISC, }; VPValue(Value *UV = nullptr, VPDef *Def = nullptr) @@ -358,15 +361,17 @@ public: // Phi-like recipes. Need to be kept together. VPBlendSC, + VPPredInstPHISC, + // Header-phi recipes. Need to be kept together. VPCanonicalIVPHISC, VPActiveLaneMaskPHISC, VPFirstOrderRecurrencePHISC, VPWidenPHISC, VPWidenIntOrFpInductionSC, VPWidenPointerInductionSC, - VPPredInstPHISC, VPReductionPHISC, VPFirstPHISC = VPBlendSC, + VPFirstHeaderPHISC = VPCanonicalIVPHISC, VPLastPHISC = VPReductionPHISC, }; -- 2.7.4