[llvm] 3157f03 - [VPlan] Add VPValue::isLiveIn() (NFC).
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Apr 24 09:51:33 PDT 2023
Author: Florian Hahn
Date: 2023-04-24T17:51:12+01:00
New Revision: 3157f03a349cfc852cdd994675eaa9652caa2e3a
URL: https://github.com/llvm/llvm-project/commit/3157f03a349cfc852cdd994675eaa9652caa2e3a
DIFF: https://github.com/llvm/llvm-project/commit/3157f03a349cfc852cdd994675eaa9652caa2e3a.diff
LOG: [VPlan] Add VPValue::isLiveIn() (NFC).
This helps to clarify checks in multiple places.
Suggested as cleanup in D147892.
Added:
Modified:
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
llvm/lib/Transforms/Vectorize/VPlan.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanValue.h
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 2cd9e0161f92..06b0c34720de 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9625,7 +9625,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)->hasDefiningRecipe()) {
+ if (isa<StoreInst>(UI) && getOperand(1)->isLiveIn()) {
auto Lane = VPLane::getLastLaneForVF(State.VF);
State.ILV->scalarizeInstruction(UI, this, VPIteration(State.UF - 1, Lane),
State);
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.cpp b/llvm/lib/Transforms/Vectorize/VPlan.cpp
index f185c9aea6bc..d0ffc2d5545a 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlan.cpp
@@ -212,7 +212,7 @@ VPBasicBlock::iterator VPBasicBlock::getFirstNonPhi() {
}
Value *VPTransformState::get(VPValue *Def, const VPIteration &Instance) {
- if (!Def->hasDefiningRecipe())
+ if (Def->isLiveIn())
return Def->getLiveInIRValue();
if (hasScalarValue(Def, Instance)) {
diff --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index 6bf2e698425d..f4cd4d83f302 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -2325,7 +2325,7 @@ class VPlan {
void setName(const Twine &newName) { Name = newName.str(); }
void addVPValue(Value *V, VPValue *VPV) {
- assert((Value2VPValueEnabled || !VPV->getDefiningRecipe()) &&
+ assert((Value2VPValueEnabled || VPV->isLiveIn()) &&
"Value2VPValue mapping may be out of date!");
assert(V && "Trying to add a null Value to VPlan");
assert(!Value2VPValue.count(V) && "Value already exists in VPlan");
@@ -2338,7 +2338,7 @@ class VPlan {
assert(V && "Trying to get the VPValue of a null Value");
assert(Value2VPValue.count(V) && "Value does not exist in VPlan");
assert((Value2VPValueEnabled || OverrideAllowed ||
- !Value2VPValue[V]->getDefiningRecipe()) &&
+ Value2VPValue[V]->isLiveIn()) &&
"Value2VPValue mapping may be out of date!");
return Value2VPValue[V];
}
diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index fee004cc92d5..e861553cb56e 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -171,16 +171,19 @@ class VPValue {
/// Returns true if this VPValue is defined by a recipe.
bool hasDefiningRecipe() const { return getDefiningRecipe(); }
+ /// Returns true if this VPValue is a live-in, i.e. defined outside the VPlan.
+ bool isLiveIn() const { return !hasDefiningRecipe(); }
+
/// 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(!hasDefiningRecipe() &&
+ assert(isLiveIn() &&
"VPValue is not a live-in; it is defined by a VPDef inside a VPlan");
return getUnderlyingValue();
}
const Value *getLiveInIRValue() const {
- assert(!hasDefiningRecipe() &&
+ assert(isLiveIn() &&
"VPValue is not a live-in; it is defined by a VPDef inside a VPlan");
return getUnderlyingValue();
}
More information about the llvm-commits
mailing list