Skip to content

Commit 8a614c1

Browse files
committed
[VPlan] Rename getVPValueOrAddLiveIn -> getOrAddLiveIn (NFCI).
The helper now only deals with live-ins, clarify the name.
1 parent a834076 commit 8a614c1

File tree

8 files changed

+31
-31
lines changed

8 files changed

+31
-31
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7905,7 +7905,7 @@ VPRecipeBuilder::mapToVPValues(User::op_range Operands) {
79057905
if (auto *R = Ingredient2Recipe.lookup(I))
79067906
return R->getVPSingleValue();
79077907
}
7908-
return Plan.getVPValueOrAddLiveIn(Op);
7908+
return Plan.getOrAddLiveIn(Op);
79097909
};
79107910
return map_range(Operands, Fn);
79117911
}
@@ -7945,7 +7945,7 @@ VPValue *VPRecipeBuilder::createEdgeMask(BasicBlock *Src, BasicBlock *Dst) {
79457945
// 'select i1 SrcMask, i1 EdgeMask, i1 false'.
79467946
// The select version does not introduce new UB if SrcMask is false and
79477947
// EdgeMask is poison. Using 'and' here introduces undefined behavior.
7948-
VPValue *False = Plan.getVPValueOrAddLiveIn(
7948+
VPValue *False = Plan.getOrAddLiveIn(
79497949
ConstantInt::getFalse(BI->getCondition()->getType()));
79507950
EdgeMask =
79517951
Builder.createSelect(SrcMask, EdgeMask, False, BI->getDebugLoc());
@@ -8147,7 +8147,7 @@ VPWidenIntOrFpInductionRecipe *VPRecipeBuilder::tryToOptimizeInductionTruncate(
81478147

81488148
auto *Phi = cast<PHINode>(I->getOperand(0));
81498149
const InductionDescriptor &II = *Legal->getIntOrFpInductionDescriptor(Phi);
8150-
VPValue *Start = Plan.getVPValueOrAddLiveIn(II.getStartValue());
8150+
VPValue *Start = Plan.getOrAddLiveIn(II.getStartValue());
81518151
return createWidenInductionRecipes(Phi, I, Start, II, Plan, *PSE.getSE(),
81528152
*OrigLoop, Range);
81538153
}
@@ -8257,7 +8257,7 @@ VPWidenCallRecipe *VPRecipeBuilder::tryToWidenCall(CallInst *CI,
82578257
if (Legal->isMaskRequired(CI))
82588258
Mask = getBlockInMask(CI->getParent());
82598259
else
8260-
Mask = Plan.getVPValueOrAddLiveIn(ConstantInt::getTrue(
8260+
Mask = Plan.getOrAddLiveIn(ConstantInt::getTrue(
82618261
IntegerType::getInt1Ty(Variant->getFunctionType()->getContext())));
82628262

82638263
Ops.insert(Ops.begin() + *MaskPos, Mask);
@@ -8301,7 +8301,7 @@ VPWidenRecipe *VPRecipeBuilder::tryToWiden(Instruction *I,
83018301
SmallVector<VPValue *> Ops(Operands.begin(), Operands.end());
83028302
VPValue *Mask = getBlockInMask(I->getParent());
83038303
VPValue *One =
8304-
Plan.getVPValueOrAddLiveIn(ConstantInt::get(I->getType(), 1u, false));
8304+
Plan.getOrAddLiveIn(ConstantInt::get(I->getType(), 1u, false));
83058305
auto *SafeRHS =
83068306
new VPInstruction(Instruction::Select, {Mask, Ops[1], One},
83078307
I->getDebugLoc());
@@ -8499,7 +8499,7 @@ void LoopVectorizationPlanner::buildVPlansWithVPRecipes(ElementCount MinVF,
84998499
static void addCanonicalIVRecipes(VPlan &Plan, Type *IdxTy, bool HasNUW,
85008500
DebugLoc DL) {
85018501
Value *StartIdx = ConstantInt::get(IdxTy, 0);
8502-
auto *StartV = Plan.getVPValueOrAddLiveIn(StartIdx);
8502+
auto *StartV = Plan.getOrAddLiveIn(StartIdx);
85038503

85048504
// Add a VPCanonicalIVPHIRecipe starting at 0 to the header.
85058505
auto *CanonicalIVPHI = new VPCanonicalIVPHIRecipe(StartV, DL);
@@ -8641,7 +8641,7 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
86418641
SmallVector<VPValue *, 4> Operands;
86428642
auto *Phi = dyn_cast<PHINode>(Instr);
86438643
if (Phi && Phi->getParent() == HeaderBB) {
8644-
Operands.push_back(Plan->getVPValueOrAddLiveIn(
8644+
Operands.push_back(Plan->getOrAddLiveIn(
86458645
Phi->getIncomingValueForBlock(OrigLoop->getLoopPreheader())));
86468646
} else {
86478647
auto OpRange = RecipeBuilder.mapToVPValues(Instr->operands());
@@ -8752,10 +8752,10 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
87528752
continue;
87538753
Constant *CI = ConstantInt::get(Stride->getType(), ScevStride->getAPInt());
87548754

8755-
auto *ConstVPV = Plan->getVPValueOrAddLiveIn(CI);
8755+
auto *ConstVPV = Plan->getOrAddLiveIn(CI);
87568756
// The versioned value may not be used in the loop directly, so just add a
87578757
// new live-in in those cases.
8758-
Plan->getVPValueOrAddLiveIn(StrideV)->replaceAllUsesWith(ConstVPV);
8758+
Plan->getOrAddLiveIn(StrideV)->replaceAllUsesWith(ConstVPV);
87598759
}
87608760

87618761
VPlanTransforms::dropPoisonGeneratingRecipes(*Plan, [this](BasicBlock *BB) {
@@ -10025,7 +10025,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1002510025
EpilogILV.setTripCount(MainILV.getTripCount());
1002610026
for (auto &R : make_early_inc_range(*BestEpiPlan.getPreheader())) {
1002710027
auto *ExpandR = cast<VPExpandSCEVRecipe>(&R);
10028-
auto *ExpandedVal = BestEpiPlan.getVPValueOrAddLiveIn(
10028+
auto *ExpandedVal = BestEpiPlan.getOrAddLiveIn(
1002910029
ExpandedSCEVs.find(ExpandR->getSCEV())->second);
1003010030
ExpandR->replaceAllUsesWith(ExpandedVal);
1003110031
if (BestEpiPlan.getTripCount() == ExpandR)
@@ -10066,7 +10066,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
1006610066
{EPI.MainLoopIterationCountCheck});
1006710067
}
1006810068
assert(ResumeV && "Must have a resume value");
10069-
VPValue *StartVal = BestEpiPlan.getVPValueOrAddLiveIn(ResumeV);
10069+
VPValue *StartVal = BestEpiPlan.getOrAddLiveIn(ResumeV);
1007010070
cast<VPHeaderPHIRecipe>(&R)->setStartValue(StartVal);
1007110071
}
1007210072

llvm/lib/Transforms/Vectorize/VPRecipeBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ class VPRecipeBuilder {
170170
if (auto *R = Ingredient2Recipe.lookup(I))
171171
return R->getVPSingleValue();
172172
}
173-
return Plan.getVPValueOrAddLiveIn(V);
173+
return Plan.getOrAddLiveIn(V);
174174
}
175175
};
176176
} // end namespace llvm

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ void VPlan::prepareToExecute(Value *TripCountV, Value *VectorTripCountV,
812812
// needs to be changed from zero to the value after the main vector loop.
813813
// FIXME: Improve modeling for canonical IV start values in the epilogue loop.
814814
if (CanonicalIVStartValue) {
815-
VPValue *VPV = getVPValueOrAddLiveIn(CanonicalIVStartValue);
815+
VPValue *VPV = getOrAddLiveIn(CanonicalIVStartValue);
816816
auto *IV = getCanonicalIV();
817817
assert(all_of(IV->users(),
818818
[](const VPUser *U) {
@@ -1088,7 +1088,7 @@ VPlan *VPlan::duplicate() {
10881088
DenseMap<VPValue *, VPValue *> Old2NewVPValues;
10891089
for (VPValue *OldLiveIn : VPLiveInsToFree) {
10901090
Old2NewVPValues[OldLiveIn] =
1091-
NewPlan->getVPValueOrAddLiveIn(OldLiveIn->getLiveInIRValue());
1091+
NewPlan->getOrAddLiveIn(OldLiveIn->getLiveInIRValue());
10921092
}
10931093
Old2NewVPValues[&VectorTripCount] = &NewPlan->VectorTripCount;
10941094
Old2NewVPValues[&VFxUF] = &NewPlan->VFxUF;
@@ -1099,7 +1099,7 @@ VPlan *VPlan::duplicate() {
10991099
assert(TripCount && "trip count must be set");
11001100
if (TripCount->isLiveIn())
11011101
Old2NewVPValues[TripCount] =
1102-
NewPlan->getVPValueOrAddLiveIn(TripCount->getLiveInIRValue());
1102+
NewPlan->getOrAddLiveIn(TripCount->getLiveInIRValue());
11031103
// else NewTripCount will be created and inserted into Old2NewVPValues when
11041104
// TripCount is cloned. In any case NewPlan->TripCount is updated below.
11051105

@@ -1422,9 +1422,9 @@ VPValue *vputils::getOrCreateVPValueForSCEVExpr(VPlan &Plan, const SCEV *Expr,
14221422
return Expanded;
14231423
VPValue *Expanded = nullptr;
14241424
if (auto *E = dyn_cast<SCEVConstant>(Expr))
1425-
Expanded = Plan.getVPValueOrAddLiveIn(E->getValue());
1425+
Expanded = Plan.getOrAddLiveIn(E->getValue());
14261426
else if (auto *E = dyn_cast<SCEVUnknown>(Expr))
1427-
Expanded = Plan.getVPValueOrAddLiveIn(E->getValue());
1427+
Expanded = Plan.getOrAddLiveIn(E->getValue());
14281428
else {
14291429
Expanded = new VPExpandSCEVRecipe(Expr, SE);
14301430
Plan.getPreheader()->appendRecipe(Expanded->getDefiningRecipe());

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3022,9 +3022,9 @@ class VPlan {
30223022
return Value2VPValue[V];
30233023
}
30243024

3025-
/// Gets the VPValue for \p V or adds a new live-in (if none exists yet) for
3026-
/// \p V.
3027-
VPValue *getVPValueOrAddLiveIn(Value *V) {
3025+
/// Gets the live-in VPValue for \p V or adds a new live-in (if none exists
3026+
/// yet) for \p V.
3027+
VPValue *getOrAddLiveIn(Value *V) {
30283028
assert(V && "Trying to get or add the VPValue of a null Value");
30293029
if (!Value2VPValue.count(V)) {
30303030
VPValue *VPV = new VPValue(V);

llvm/lib/Transforms/Vectorize/VPlanHCFGBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ VPValue *PlainCFGBuilder::getOrCreateVPOperand(Value *IRVal) {
272272

273273
// A and B: Create VPValue and add it to the pool of external definitions and
274274
// to the Value->VPValue map.
275-
VPValue *NewVPVal = Plan.getVPValueOrAddLiveIn(IRVal);
275+
VPValue *NewVPVal = Plan.getOrAddLiveIn(IRVal);
276276
IRDef2VPValue[IRVal] = NewVPVal;
277277
return NewVPVal;
278278
}
@@ -361,7 +361,7 @@ void PlainCFGBuilder::buildPlainCFG() {
361361
for (auto &I : *ThePreheaderBB) {
362362
if (I.getType()->isVoidTy())
363363
continue;
364-
IRDef2VPValue[&I] = Plan.getVPValueOrAddLiveIn(&I);
364+
IRDef2VPValue[&I] = Plan.getOrAddLiveIn(&I);
365365
}
366366

367367
LoopBlocksRPO RPO(TheLoop);

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
5252
if (!II)
5353
continue;
5454

55-
VPValue *Start = Plan->getVPValueOrAddLiveIn(II->getStartValue());
55+
VPValue *Start = Plan->getOrAddLiveIn(II->getStartValue());
5656
VPValue *Step =
5757
vputils::getOrCreateVPValueForSCEVExpr(*Plan, II->getStep(), SE);
5858
NewRecipe = new VPWidenIntOrFpInductionRecipe(Phi, Start, Step, *II);
@@ -568,8 +568,8 @@ static void legalizeAndOptimizeInductions(VPlan &Plan, ScalarEvolution &SE) {
568568
continue;
569569

570570
const InductionDescriptor &ID = PtrIV->getInductionDescriptor();
571-
VPValue *StartV = Plan.getVPValueOrAddLiveIn(
572-
ConstantInt::get(ID.getStep()->getType(), 0));
571+
VPValue *StartV =
572+
Plan.getOrAddLiveIn(ConstantInt::get(ID.getStep()->getType(), 0));
573573
VPValue *StepV = PtrIV->getOperand(1);
574574
VPRecipeBase *Steps =
575575
createScalarIVSteps(Plan, InductionDescriptor::IK_IntInduction,
@@ -663,9 +663,9 @@ void VPlanTransforms::optimizeForVFAndUF(VPlan &Plan, ElementCount BestVF,
663663
return;
664664

665665
LLVMContext &Ctx = SE.getContext();
666-
auto *BOC = new VPInstruction(
667-
VPInstruction::BranchOnCond,
668-
{Plan.getVPValueOrAddLiveIn(ConstantInt::getTrue(Ctx))});
666+
auto *BOC =
667+
new VPInstruction(VPInstruction::BranchOnCond,
668+
{Plan.getOrAddLiveIn(ConstantInt::getTrue(Ctx))});
669669
Term->eraseFromParent();
670670
ExitingVPBB->appendRecipe(BOC);
671671
Plan.setVF(BestVF);

llvm/unittests/Transforms/Vectorize/VPlanHCFGTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ TEST_F(VPlanHCFGTest, testBuildHCFGInnerLoop) {
9696
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
9797
// Add an external value to check we do not print the list of external values,
9898
// as this is not required with the new printing.
99-
Plan->getVPValueOrAddLiveIn(&*F->arg_begin());
99+
Plan->getOrAddLiveIn(&*F->arg_begin());
100100
std::string FullDump;
101101
raw_string_ostream OS(FullDump);
102102
Plan->printDOT(OS);

llvm/unittests/Transforms/Vectorize/VPlanTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,8 @@ TEST(VPRecipeTest, dump) {
12371237
BinaryOperator::CreateAdd(UndefValue::get(Int32), UndefValue::get(Int32));
12381238
AI->setName("a");
12391239
SmallVector<VPValue *, 2> Args;
1240-
VPValue *ExtVPV1 = Plan.getVPValueOrAddLiveIn(ConstantInt::get(Int32, 1));
1241-
VPValue *ExtVPV2 = Plan.getVPValueOrAddLiveIn(ConstantInt::get(Int32, 2));
1240+
VPValue *ExtVPV1 = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 1));
1241+
VPValue *ExtVPV2 = Plan.getOrAddLiveIn(ConstantInt::get(Int32, 2));
12421242
Args.push_back(ExtVPV1);
12431243
Args.push_back(ExtVPV2);
12441244
VPWidenRecipe *WidenR =

0 commit comments

Comments
 (0)