[llvm] 55f56cd - [VPlan] Introduce VPValue::hasDefiningRecipe helper (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 16 15:13:04 PST 2022
Author: Florian Hahn
Date: 2022-11-16T23:12:40Z
New Revision: 55f56cdc3329b9af059caf7fd5df01fe4e54eb14
URL: https://github.com/llvm/llvm-project/commit/55f56cdc3329b9af059caf7fd5df01fe4e54eb14
DIFF: https://github.com/llvm/llvm-project/commit/55f56cdc3329b9af059caf7fd5df01fe4e54eb14.diff
LOG: [VPlan] Introduce VPValue::hasDefiningRecipe helper (NFC).
This clarifies the intention of code that uses the helper.
Suggested by @Ayal during review of D136068, thanks!
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
llvm/lib/Transforms/Vectorize/VPlanValue.h
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 99e7f59b6f35..ba10a4702f71 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<StoreInst>(UI) && !getOperand(1)->getDefiningRecipe()) {
+ if (isa<StoreInst>(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 d4e8d863ac82..01b616fc1f5b 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 010ada40fb0e..39f28f8b0e95 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<ConstantInt>(StepVPV->getLiveInIRValue());
return StepC && StepC->isOne();
diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index 35d8854da2da..7df99dd080a2 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -187,16 +187,19 @@ class VPValue {
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 @@ class VPValue {
/// 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<Value *, VPValue *> Value2VPValueTy;
More information about the llvm-commits
mailing list