Skip to content

Commit 734a204

Browse files
committed
[VPlan] Manage VPWidenIntOrFPInduction debug location via recipe (NFC).
Properly set VPWidenIntOrFpInductionRecipe's debug location in the recipe and use it, instead of using the debug location of the underlying IR instruction.
1 parent 916bae2 commit 734a204

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8439,11 +8439,12 @@ createWidenInductionRecipes(PHINode *Phi, Instruction *PhiOrTrunc,
84398439
vputils::getOrCreateVPValueForSCEVExpr(Plan, IndDesc.getStep(), SE);
84408440
if (auto *TruncI = dyn_cast<TruncInst>(PhiOrTrunc)) {
84418441
return new VPWidenIntOrFpInductionRecipe(Phi, Start, Step, &Plan.getVF(),
8442-
IndDesc, TruncI);
8442+
IndDesc, TruncI,
8443+
TruncI->getDebugLoc());
84438444
}
84448445
assert(isa<PHINode>(PhiOrTrunc) && "must be a phi node here");
84458446
return new VPWidenIntOrFpInductionRecipe(Phi, Start, Step, &Plan.getVF(),
8446-
IndDesc);
8447+
IndDesc, Phi->getDebugLoc());
84478448
}
84488449

84498450
VPHeaderPHIRecipe *VPRecipeBuilder::tryToOptimizeInductionPHI(

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2108,17 +2108,18 @@ class VPWidenIntOrFpInductionRecipe : public VPHeaderPHIRecipe {
21082108

21092109
public:
21102110
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, VPValue *Step,
2111-
VPValue *VF, const InductionDescriptor &IndDesc)
2112-
: VPHeaderPHIRecipe(VPDef::VPWidenIntOrFpInductionSC, IV, Start), IV(IV),
2113-
Trunc(nullptr), IndDesc(IndDesc) {
2111+
VPValue *VF, const InductionDescriptor &IndDesc,
2112+
DebugLoc DL)
2113+
: VPHeaderPHIRecipe(VPDef::VPWidenIntOrFpInductionSC, IV, Start, DL),
2114+
IV(IV), Trunc(nullptr), IndDesc(IndDesc) {
21142115
addOperand(Step);
21152116
addOperand(VF);
21162117
}
21172118

21182119
VPWidenIntOrFpInductionRecipe(PHINode *IV, VPValue *Start, VPValue *Step,
21192120
VPValue *VF, const InductionDescriptor &IndDesc,
2120-
TruncInst *Trunc)
2121-
: VPHeaderPHIRecipe(VPDef::VPWidenIntOrFpInductionSC, Trunc, Start),
2121+
TruncInst *Trunc, DebugLoc DL)
2122+
: VPHeaderPHIRecipe(VPDef::VPWidenIntOrFpInductionSC, Trunc, Start, DL),
21222123
IV(IV), Trunc(Trunc), IndDesc(IndDesc) {
21232124
addOperand(Step);
21242125
addOperand(VF);
@@ -2127,8 +2128,9 @@ class VPWidenIntOrFpInductionRecipe : public VPHeaderPHIRecipe {
21272128
~VPWidenIntOrFpInductionRecipe() override = default;
21282129

21292130
VPWidenIntOrFpInductionRecipe *clone() override {
2130-
return new VPWidenIntOrFpInductionRecipe(
2131-
IV, getStartValue(), getStepValue(), getVFValue(), IndDesc, Trunc);
2131+
return new VPWidenIntOrFpInductionRecipe(IV, getStartValue(),
2132+
getStepValue(), getVFValue(),
2133+
IndDesc, Trunc, getDebugLoc());
21322134
}
21332135

21342136
VP_CLASSOF_IMPL(VPDef::VPWidenIntOrFpInductionSC)

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1733,14 +1733,14 @@ void VPWidenIntOrFpInductionRecipe::execute(VPTransformState &State) {
17331733
// factor. The last of those goes into the PHI.
17341734
PHINode *VecInd = PHINode::Create(SteppedStart->getType(), 2, "vec.ind");
17351735
VecInd->insertBefore(State.CFG.PrevBB->getFirstInsertionPt());
1736-
VecInd->setDebugLoc(EntryVal->getDebugLoc());
1736+
VecInd->setDebugLoc(getDebugLoc());
17371737
State.set(this, VecInd);
17381738

17391739
Instruction *LastInduction = cast<Instruction>(
17401740
Builder.CreateBinOp(AddOp, VecInd, SplatVF, "vec.ind.next"));
17411741
if (isa<TruncInst>(EntryVal))
17421742
State.addMetadata(LastInduction, EntryVal);
1743-
LastInduction->setDebugLoc(EntryVal->getDebugLoc());
1743+
LastInduction->setDebugLoc(getDebugLoc());
17441744

17451745
VecInd->addIncoming(SteppedStart, VectorPH);
17461746
// Add induction update using an incorrect block temporarily. The phi node

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
6161
VPValue *Start = Plan->getOrAddLiveIn(II->getStartValue());
6262
VPValue *Step =
6363
vputils::getOrCreateVPValueForSCEVExpr(*Plan, II->getStep(), SE);
64-
NewRecipe = new VPWidenIntOrFpInductionRecipe(Phi, Start, Step,
65-
&Plan->getVF(), *II);
64+
NewRecipe = new VPWidenIntOrFpInductionRecipe(
65+
Phi, Start, Step, &Plan->getVF(), *II, Ingredient.getDebugLoc());
6666
} else {
6767
assert(isa<VPInstruction>(&Ingredient) &&
6868
"only VPInstructions expected here");

0 commit comments

Comments
 (0)