Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4207,7 +4207,7 @@ VectorizationFactor LoopVectorizationPlanner::selectVectorizationFactor() {
// divisors.
case Instruction::Select: {
VPValue *VPV = VPI->getVPSingleValue();
if (VPV->getNumUsers() == 1) {
if (VPV->getNumUses() == 1) {
if (auto *WR = dyn_cast<VPWidenRecipe>(*VPV->user_begin())) {
switch (WR->getOpcode()) {
case Instruction::UDiv:
Expand Down
14 changes: 7 additions & 7 deletions llvm/lib/Transforms/Vectorize/VPlan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1056,25 +1056,25 @@ const VPRegionBlock *VPlan::getVectorLoopRegion() const {
void VPlan::printLiveIns(raw_ostream &O) const {
VPSlotTracker SlotTracker(this);

if (VF.getNumUsers() > 0) {
if (VF.getNumUses() > 0) {
O << "\nLive-in ";
VF.printAsOperand(O, SlotTracker);
O << " = VF";
}

if (VFxUF.getNumUsers() > 0) {
if (VFxUF.getNumUses() > 0) {
O << "\nLive-in ";
VFxUF.printAsOperand(O, SlotTracker);
O << " = VF * UF";
}

if (VectorTripCount.getNumUsers() > 0) {
if (VectorTripCount.getNumUses() > 0) {
O << "\nLive-in ";
VectorTripCount.printAsOperand(O, SlotTracker);
O << " = vector-trip-count";
}

if (BackedgeTakenCount && BackedgeTakenCount->getNumUsers()) {
if (BackedgeTakenCount && BackedgeTakenCount->getNumUses()) {
O << "\nLive-in ";
BackedgeTakenCount->printAsOperand(O, SlotTracker);
O << " = backedge-taken count";
Expand Down Expand Up @@ -1416,7 +1416,7 @@ void VPValue::replaceUsesWithIf(
if (this == New)
return;

for (unsigned J = 0; J < getNumUsers();) {
for (unsigned J = 0; J < getNumUses();) {
VPUser *User = Users[J];
bool RemovedUser = false;
for (unsigned I = 0, E = User->getNumOperands(); I < E; ++I) {
Expand Down Expand Up @@ -1492,9 +1492,9 @@ void VPSlotTracker::assignName(const VPValue *V) {
}

void VPSlotTracker::assignNames(const VPlan &Plan) {
if (Plan.VF.getNumUsers() > 0)
if (Plan.VF.getNumUses() > 0)
assignName(&Plan.VF);
if (Plan.VFxUF.getNumUsers() > 0)
if (Plan.VFxUF.getNumUses() > 0)
assignName(&Plan.VFxUF);
assignName(&Plan.VectorTripCount);
if (Plan.BackedgeTakenCount)
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/VPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -4204,7 +4204,7 @@ class VPlan {
/// Resets the trip count for the VPlan. The caller must make sure all uses of
/// the original trip count have been replaced.
void resetTripCount(VPValue *NewTripCount) {
assert(TripCount && NewTripCount && TripCount->getNumUsers() == 0 &&
assert(TripCount && NewTripCount && TripCount->getNumUses() == 0 &&
"TripCount must be set when resetting");
TripCount = NewTripCount;
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/VPlanConstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ bool VPlanTransforms::handleMaxMinNumReductions(VPlan &Plan) {
if (VecV == RdxResult)
continue;
if (auto *DerivedIV = dyn_cast<VPDerivedIVRecipe>(VecV)) {
if (DerivedIV->getNumUsers() == 1 &&
if (DerivedIV->getNumUses() == 1 &&
DerivedIV->getOperand(1) == &Plan.getVectorTripCount()) {
auto *NewSel = Builder.createSelect(AnyNaN, Plan.getCanonicalIV(),
&Plan.getVectorTripCount());
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2249,7 +2249,7 @@ InstructionCost VPWidenCastRecipe::computeCost(ElementCount VF,
TTI::CastContextHint CCH = TTI::CastContextHint::None;
// For Trunc/FPTrunc, get the context from the only user.
if ((Opcode == Instruction::Trunc || Opcode == Instruction::FPTrunc) &&
!hasMoreThanOneUniqueUser() && getNumUsers() > 0) {
!hasMoreThanOneUniqueUser() && getNumUses() > 0) {
if (auto *StoreRecipe = dyn_cast<VPRecipeBase>(*user_begin()))
CCH = ComputeCCH(StoreRecipe);
}
Expand Down
26 changes: 13 additions & 13 deletions llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ static bool mergeReplicateRegionsIntoSuccessors(VPlan &Plan) {
});

// Remove phi recipes that are unused after merging the regions.
if (Phi1ToMove.getVPSingleValue()->getNumUsers() == 0) {
if (Phi1ToMove.getVPSingleValue()->getNumUses() == 0) {
Phi1ToMove.eraseFromParent();
continue;
}
Expand Down Expand Up @@ -363,7 +363,7 @@ static VPRegionBlock *createReplicateRegion(VPReplicateRecipe *PredRecipe,
Plan.createVPBasicBlock(Twine(RegionName) + ".if", RecipeWithoutMask);

VPPredInstPHIRecipe *PHIRecipe = nullptr;
if (PredRecipe->getNumUsers() != 0) {
if (PredRecipe->getNumUses() != 0) {
PHIRecipe = new VPPredInstPHIRecipe(RecipeWithoutMask,
RecipeWithoutMask->getDebugLoc());
PredRecipe->replaceAllUsesWith(PHIRecipe);
Expand Down Expand Up @@ -547,7 +547,7 @@ static bool isDeadRecipe(VPRecipeBase &R) {

// Recipe is dead if no user keeps the recipe alive.
return all_of(R.definedValues(),
[](VPValue *V) { return V->getNumUsers() == 0; });
[](VPValue *V) { return V->getNumUses() == 0; });
}

void VPlanTransforms::removeDeadRecipes(VPlan &Plan) {
Expand All @@ -563,11 +563,11 @@ void VPlanTransforms::removeDeadRecipes(VPlan &Plan) {

// Check if R is a dead VPPhi <-> update cycle and remove it.
auto *PhiR = dyn_cast<VPPhi>(&R);
if (!PhiR || PhiR->getNumOperands() != 2 || PhiR->getNumUsers() != 1)
if (!PhiR || PhiR->getNumOperands() != 2 || PhiR->getNumUses() != 1)
continue;
VPValue *Incoming = PhiR->getOperand(1);
if (*PhiR->user_begin() != Incoming->getDefiningRecipe() ||
Incoming->getNumUsers() != 1)
Incoming->getNumUses() != 1)
continue;
PhiR->replaceAllUsesWith(PhiR->getOperand(0));
PhiR->eraseFromParent();
Expand Down Expand Up @@ -658,7 +658,7 @@ static void legalizeAndOptimizeInductions(VPlan &Plan) {
auto *RepR = dyn_cast<VPReplicateRecipe>(U);
// Skip recipes that shouldn't be narrowed.
if (!Def || !isa<VPReplicateRecipe, VPWidenRecipe>(Def) ||
Def->getNumUsers() == 0 || !Def->getUnderlyingValue() ||
Def->getNumUses() == 0 || !Def->getUnderlyingValue() ||
(RepR && (RepR->isSingleScalar() || RepR->isPredicated())))
continue;

Expand Down Expand Up @@ -1344,7 +1344,7 @@ static void simplifyBlends(VPlan &Plan) {
// TODO: Find the most expensive mask that can be deadcoded, or a mask
// that's used by multiple blends where it can be removed from them all.
VPValue *Mask = Blend->getMask(I);
if (Mask->getNumUsers() == 1 && !match(Mask, m_False())) {
if (Mask->getNumUses() == 1 && !match(Mask, m_False())) {
StartIndex = I;
break;
}
Expand Down Expand Up @@ -1380,7 +1380,7 @@ static void simplifyBlends(VPlan &Plan) {
NewBlend->setOperand(0, Inc1);
NewBlend->setOperand(1, Inc0);
NewBlend->setOperand(2, NewMask);
if (OldMask->getNumUsers() == 0)
if (OldMask->getNumUses() == 0)
cast<VPInstruction>(OldMask)->eraseFromParent();
}
}
Expand Down Expand Up @@ -2467,7 +2467,7 @@ static void transformRecipestoEVLRecipes(VPlan &Plan, VPValue &EVL) {
ToErase.push_back(CurRecipe);
}
// Remove dead EVL mask.
if (EVLMask->getNumUsers() == 0)
if (EVLMask->getNumUses() == 0)
ToErase.push_back(EVLMask->getDefiningRecipe());

for (VPRecipeBase *R : reverse(ToErase)) {
Expand Down Expand Up @@ -3445,7 +3445,7 @@ void VPlanTransforms::materializeBroadcasts(VPlan &Plan) {
#endif

SmallVector<VPValue *> VPValues;
if (Plan.getOrCreateBackedgeTakenCount()->getNumUsers() > 0)
if (Plan.getOrCreateBackedgeTakenCount()->getNumUses() > 0)
VPValues.push_back(Plan.getOrCreateBackedgeTakenCount());
append_range(VPValues, Plan.getLiveIns());
for (VPRecipeBase &R : *Plan.getEntry())
Expand Down Expand Up @@ -3514,7 +3514,7 @@ void VPlanTransforms::materializeConstantVectorTripCount(
void VPlanTransforms::materializeBackedgeTakenCount(VPlan &Plan,
VPBasicBlock *VectorPH) {
VPValue *BTC = Plan.getOrCreateBackedgeTakenCount();
if (BTC->getNumUsers() == 0)
if (BTC->getNumUses() == 0)
return;

VPBuilder Builder(VectorPH, VectorPH->begin());
Expand Down Expand Up @@ -3580,7 +3580,7 @@ void VPlanTransforms::materializeVectorTripCount(VPlan &Plan,
assert(VectorTC.isLiveIn() && "vector-trip-count must be a live-in");
// There's nothing to do if there are no users of the vector trip count or its
// IR value has already been set.
if (VectorTC.getNumUsers() == 0 || VectorTC.getLiveInIRValue())
if (VectorTC.getNumUses() == 0 || VectorTC.getLiveInIRValue())
return;

VPValue *TC = Plan.getTripCount();
Expand Down Expand Up @@ -3645,7 +3645,7 @@ void VPlanTransforms::materializeVFAndVFxUF(VPlan &Plan, VPBasicBlock *VectorPH,

// If there are no users of the runtime VF, compute VFxUF by constant folding
// the multiplication of VF and UF.
if (VF.getNumUsers() == 0) {
if (VF.getNumUses() == 0) {
VPValue *RuntimeVFxUF =
Builder.createElementCount(TCTy, VFEC * Plan.getUF());
VFxUF.replaceAllUsesWith(RuntimeVFxUF);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/Vectorize/VPlanUnroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ void VPlanTransforms::replicateByVF(VPlan &Plan, ElementCount VF) {
continue;

VPBuilder Builder(RepR);
if (RepR->getNumUsers() == 0) {
if (RepR->getNumUses() == 0) {
if (isa<StoreInst>(RepR->getUnderlyingInstr()) &&
vputils::isSingleScalar(RepR->getOperand(1))) {
// Stores to invariant addresses need to store the last lane only.
Expand Down
23 changes: 14 additions & 9 deletions llvm/lib/Transforms/Vectorize/VPlanValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,18 @@ class LLVM_ABI_FOR_TEST VPValue {
void dump() const;
#endif

unsigned getNumUsers() const { return Users.size(); }
/// Returns the number of uses of this VPValue. The same user could appear
/// more than once in the list due to this value being used for multiple
/// operands in a recipe.
unsigned getNumUses() const { return Users.size(); }

/// Adds a user of this value to the list.
void addUser(VPUser &User) { Users.push_back(&User); }

/// Remove a single \p User from the list of users.
void removeUser(VPUser &User) {
/// Remove the first instance of \p User from the list of uses.
void removeFirstUse(VPUser &User) {
// The same user can be added multiple times, e.g. because the same VPValue
// is used twice by the same VPUser. Remove a single one.
// is used twice by the same VPUser. Remove the first one.
auto *I = find(Users, &User);
if (I != Users.end())
Users.erase(I);
Expand All @@ -138,7 +143,7 @@ class LLVM_ABI_FOR_TEST VPValue {

/// Returns true if the value has more than one unique user.
bool hasMoreThanOneUniqueUser() const {
if (getNumUsers() == 0)
if (getNumUses() == 0)
return false;

// Check if all users match the first user.
Expand Down Expand Up @@ -203,7 +208,7 @@ class VPUser {
/// Removes the operand at index \p Idx. This also removes the VPUser from the
/// use-list of the operand.
void removeOperand(unsigned Idx) {
getOperand(Idx)->removeUser(*this);
getOperand(Idx)->removeFirstUse(*this);
Operands.erase(Operands.begin() + Idx);
}

Expand All @@ -224,7 +229,7 @@ class VPUser {
VPUser &operator=(const VPUser &) = delete;
virtual ~VPUser() {
for (VPValue *Op : operands())
Op->removeUser(*this);
Op->removeFirstUse(*this);
}

void addOperand(VPValue *Operand) {
Expand All @@ -239,7 +244,7 @@ class VPUser {
}

void setOperand(unsigned I, VPValue *New) {
Operands[I]->removeUser(*this);
Operands[I]->removeFirstUse(*this);
Operands[I] = New;
New->addUser(*this);
}
Expand Down Expand Up @@ -383,7 +388,7 @@ class VPDef {
for (VPValue *D : make_early_inc_range(DefinedValues)) {
assert(D->Def == this &&
"all defined VPValues should point to the containing VPDef");
assert(D->getNumUsers() == 0 &&
assert(D->getNumUses() == 0 &&
"all defined VPValues should have no more users");
D->Def = nullptr;
delete D;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Vectorize/VPlanVerifier.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,8 @@ bool VPlanVerifier::verifyEVLRecipe(const VPInstruction &EVL) const {
}
// EVLIVIncrement is only used by EVLIV & BranchOnCount.
// Having more than two users is unexpected.
if ((I->getNumUsers() != 1) &&
(I->getNumUsers() != 2 || none_of(I->users(), [&I](VPUser *U) {
if ((I->getNumUses() != 1) &&
(I->getNumUses() != 2 || none_of(I->users(), [&I](VPUser *U) {
using namespace llvm::VPlanPatternMatch;
return match(U, m_BranchOnCount(m_Specific(I), m_VPValue()));
}))) {
Expand Down
Loading
Loading