Skip to content

Commit d1f2a66

Browse files
committed
[VPlan] Pass debug location explicitly to VPBlendRecipe (NFC).
This enables creating VPBlendRecipes without underlying PHINode.
1 parent ea6106b commit d1f2a66

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,14 +2308,15 @@ class LLVM_ABI_FOR_TEST VPBlendRecipe : public VPSingleDefRecipe {
23082308
/// respective masks, ordered [I0, M0, I1, M1, I2, M2, ...]. Note that M0 can
23092309
/// be omitted (implied by passing an odd number of operands) in which case
23102310
/// all other incoming values are merged into it.
2311-
VPBlendRecipe(PHINode *Phi, ArrayRef<VPValue *> Operands)
2312-
: VPSingleDefRecipe(VPDef::VPBlendSC, Operands, Phi, Phi->getDebugLoc()) {
2311+
VPBlendRecipe(PHINode *Phi, ArrayRef<VPValue *> Operands, DebugLoc DL)
2312+
: VPSingleDefRecipe(VPDef::VPBlendSC, Operands, Phi, DL) {
23132313
assert(Operands.size() > 0 && "Expected at least one operand!");
23142314
}
23152315

23162316
VPBlendRecipe *clone() override {
23172317
SmallVector<VPValue *> Ops(operands());
2318-
return new VPBlendRecipe(cast<PHINode>(getUnderlyingValue()), Ops);
2318+
return new VPBlendRecipe(cast_or_null<PHINode>(getUnderlyingValue()), Ops,
2319+
getDebugLoc());
23192320
}
23202321

23212322
VP_CLASSOF_IMPL(VPDef::VPBlendSC)

llvm/lib/Transforms/Vectorize/VPlanPredicator.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,9 @@ void VPPredicator::convertPhisToBlends(VPBasicBlock *VPBB) {
251251
}
252252
OperandsWithMask.push_back(EdgeMask);
253253
}
254-
PHINode *IRPhi = cast<PHINode>(PhiR->getUnderlyingValue());
255-
auto *Blend = new VPBlendRecipe(IRPhi, OperandsWithMask);
254+
PHINode *IRPhi = cast_or_null<PHINode>(PhiR->getUnderlyingValue());
255+
auto *Blend =
256+
new VPBlendRecipe(IRPhi, OperandsWithMask, PhiR->getDebugLoc());
256257
Builder.insert(Blend);
257258
PhiR->replaceAllUsesWith(Blend);
258259
PhiR->eraseFromParent();

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1307,8 +1307,9 @@ static void simplifyBlends(VPlan &Plan) {
13071307
OperandsWithMask.push_back(Blend->getMask(I));
13081308
}
13091309

1310-
auto *NewBlend = new VPBlendRecipe(
1311-
cast<PHINode>(Blend->getUnderlyingValue()), OperandsWithMask);
1310+
auto *NewBlend =
1311+
new VPBlendRecipe(cast_or_null<PHINode>(Blend->getUnderlyingValue()),
1312+
OperandsWithMask, Blend->getDebugLoc());
13121313
NewBlend->insertBefore(&R);
13131314

13141315
VPValue *DeadMask = Blend->getMask(StartIndex);

llvm/unittests/Transforms/Vectorize/VPlanTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ TEST_F(VPRecipeTest, CastVPBlendRecipeToVPUser) {
10751075
Args.push_back(I1);
10761076
Args.push_back(I2);
10771077
Args.push_back(M2);
1078-
VPBlendRecipe Recipe(Phi, Args);
1078+
VPBlendRecipe Recipe(Phi, Args, {});
10791079
EXPECT_TRUE(isa<VPUser>(&Recipe));
10801080
VPRecipeBase *BaseR = &Recipe;
10811081
EXPECT_TRUE(isa<VPUser>(BaseR));

llvm/unittests/Transforms/Vectorize/VPlanVerifierTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ TEST_F(VPVerifierTest, VPBlendUseBeforeDefDifferentBB) {
103103
auto *CanIV = new VPCanonicalIVPHIRecipe(Zero, {});
104104
VPInstruction *BranchOnCond =
105105
new VPInstruction(VPInstruction::BranchOnCond, {CanIV});
106-
auto *Blend = new VPBlendRecipe(Phi, {DefI});
106+
auto *Blend = new VPBlendRecipe(Phi, {DefI}, {});
107107

108108
VPBasicBlock *VPBB1 = Plan.getEntry();
109109
VPBasicBlock *VPBB2 = Plan.createVPBasicBlock("");

0 commit comments

Comments
 (0)