From 55f56cdc3329b9af059caf7fd5df01fe4e54eb14 Mon Sep 17 00:00:00 2001 From: Florian Hahn Date: Wed, 16 Nov 2022 23:12:40 +0000 Subject: [PATCH] [VPlan] Introduce VPValue::hasDefiningRecipe helper (NFC). This clarifies the intention of code that uses the helper. Suggested by @Ayal during review of D136068, thanks! --- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 2 +- llvm/lib/Transforms/Vectorize/VPlan.cpp | 2 +- llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp | 2 +- llvm/lib/Transforms/Vectorize/VPlanValue.h | 9 ++++++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 99e7f59..ba10a47 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -9656,7 +9656,7 @@ void VPReplicateRecipe::execute(VPTransformState &State) { // A store of a loop varying value to a loop invariant address only // needs only the last copy of the store. - if (isa(UI) && !getOperand(1)->getDefiningRecipe()) { + if (isa(UI) && !getOperand(1)->hasDefiningRecipe()) { auto Lane = VPLane::getLastLaneForVF(State.VF); State.ILV->scalarizeInstruction(UI, this, VPIteration(State.UF - 1, Lane), IsPredicated, State); diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp index d4e8d86..01b616f 100644 --- a/llvm/lib/Transforms/Vectorize/VPlan.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp @@ -210,7 +210,7 @@ VPBasicBlock::iterator VPBasicBlock::getFirstNonPhi() { } Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) { - if (!Def->getDefiningRecipe()) + if (!Def->hasDefiningRecipe()) return Def->getLiveInIRValue(); if (hasScalarValue(Def, Instance)) { diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp index 010ada4..39f28f8 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp +++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp @@ -723,7 +723,7 @@ bool VPScalarIVStepsRecipe::isCanonical() const { if (CanIV->getStartValue() != getStartValue()) return false; auto *StepVPV = getStepValue(); - if (StepVPV->getDefiningRecipe()) + if (StepVPV->hasDefiningRecipe()) return false; auto *StepC = dyn_cast_or_null(StepVPV->getLiveInIRValue()); return StepC && StepC->isOne(); diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h index 35d8854..7df99dd 100644 --- a/llvm/lib/Transforms/Vectorize/VPlanValue.h +++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h @@ -187,16 +187,19 @@ public: VPRecipeBase *getDefiningRecipe(); const VPRecipeBase *getDefiningRecipe() const; + /// Returns true if this VPValue is defined by a recipe. + bool hasDefiningRecipe() const { return getDefiningRecipe(); } + /// Returns the underlying IR value, if this VPValue is defined outside the /// scope of VPlan. Returns nullptr if the VPValue is defined by a VPDef /// inside a VPlan. Value *getLiveInIRValue() { - assert(!getDefiningRecipe() && + assert(!hasDefiningRecipe() && "VPValue is not a live-in; it is defined by a VPDef inside a VPlan"); return getUnderlyingValue(); } const Value *getLiveInIRValue() const { - assert(!getDefiningRecipe() && + assert(!hasDefiningRecipe() && "VPValue is not a live-in; it is defined by a VPDef inside a VPlan"); return getUnderlyingValue(); } @@ -204,7 +207,7 @@ public: /// Returns true if the VPValue is defined outside any vector regions, i.e. it /// is a live-in value. /// TODO: Also handle recipes defined in pre-header blocks. - bool isDefinedOutsideVectorRegions() const { return !getDefiningRecipe(); } + bool isDefinedOutsideVectorRegions() const { return !hasDefiningRecipe(); } }; typedef DenseMap Value2VPValueTy; -- 2.7.4