Skip to content

Commit e701c1a

Browse files
committed
[VPlan] Use recipe's debug loc for VPWidenMemoryInstructionRecipe (NFCI)
Now that VPRecipeBase manages debug locations for recipes, use it in VPWidenMemoryInstructionRecipe.
1 parent c9bcb2b commit e701c1a

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8074,11 +8074,11 @@ VPRecipeBuilder::tryToWidenMemory(Instruction *I, ArrayRef<VPValue *> Operands,
80748074
}
80758075
if (LoadInst *Load = dyn_cast<LoadInst>(I))
80768076
return new VPWidenMemoryInstructionRecipe(*Load, Ptr, Mask, Consecutive,
8077-
Reverse);
8077+
Reverse, I->getDebugLoc());
80788078

80798079
StoreInst *Store = cast<StoreInst>(I);
8080-
return new VPWidenMemoryInstructionRecipe(*Store, Ptr, Operands[0], Mask,
8081-
Consecutive, Reverse);
8080+
return new VPWidenMemoryInstructionRecipe(
8081+
*Store, Ptr, Operands[0], Mask, Consecutive, Reverse, I->getDebugLoc());
80828082
}
80838083

80848084
/// Creates a VPWidenIntOrFpInductionRecpipe for \p Phi. If needed, it will also
@@ -9340,7 +9340,7 @@ void VPWidenMemoryInstructionRecipe::execute(VPTransformState &State) {
93409340

93419341
// Handle Stores:
93429342
if (SI) {
9343-
State.setDebugLocFrom(SI->getDebugLoc());
9343+
State.setDebugLocFrom(getDebugLoc());
93449344

93459345
for (unsigned Part = 0; Part < State.UF; ++Part) {
93469346
Instruction *NewSI = nullptr;
@@ -9372,7 +9372,7 @@ void VPWidenMemoryInstructionRecipe::execute(VPTransformState &State) {
93729372

93739373
// Handle loads.
93749374
assert(LI && "Must have a load instruction");
9375-
State.setDebugLocFrom(LI->getDebugLoc());
9375+
State.setDebugLocFrom(getDebugLoc());
93769376
for (unsigned Part = 0; Part < State.UF; ++Part) {
93779377
Value *NewLI;
93789378
if (CreateGatherScatter) {

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,8 +2278,8 @@ class VPWidenMemoryInstructionRecipe : public VPRecipeBase {
22782278

22792279
public:
22802280
VPWidenMemoryInstructionRecipe(LoadInst &Load, VPValue *Addr, VPValue *Mask,
2281-
bool Consecutive, bool Reverse)
2282-
: VPRecipeBase(VPDef::VPWidenMemoryInstructionSC, {Addr}),
2281+
bool Consecutive, bool Reverse, DebugLoc DL)
2282+
: VPRecipeBase(VPDef::VPWidenMemoryInstructionSC, {Addr}, DL),
22832283
Ingredient(Load), Consecutive(Consecutive), Reverse(Reverse) {
22842284
assert((Consecutive || !Reverse) && "Reverse implies consecutive");
22852285
new VPValue(this, &Load);
@@ -2288,8 +2288,9 @@ class VPWidenMemoryInstructionRecipe : public VPRecipeBase {
22882288

22892289
VPWidenMemoryInstructionRecipe(StoreInst &Store, VPValue *Addr,
22902290
VPValue *StoredValue, VPValue *Mask,
2291-
bool Consecutive, bool Reverse)
2292-
: VPRecipeBase(VPDef::VPWidenMemoryInstructionSC, {Addr, StoredValue}),
2291+
bool Consecutive, bool Reverse, DebugLoc DL)
2292+
: VPRecipeBase(VPDef::VPWidenMemoryInstructionSC, {Addr, StoredValue},
2293+
DL),
22932294
Ingredient(Store), Consecutive(Consecutive), Reverse(Reverse) {
22942295
assert((Consecutive || !Reverse) && "Reverse implies consecutive");
22952296
setMask(Mask);
@@ -2299,10 +2300,11 @@ class VPWidenMemoryInstructionRecipe : public VPRecipeBase {
22992300
if (isStore())
23002301
return new VPWidenMemoryInstructionRecipe(
23012302
cast<StoreInst>(Ingredient), getAddr(), getStoredValue(), getMask(),
2302-
Consecutive, Reverse);
2303+
Consecutive, Reverse, getDebugLoc());
23032304

2304-
return new VPWidenMemoryInstructionRecipe(
2305-
cast<LoadInst>(Ingredient), getAddr(), getMask(), Consecutive, Reverse);
2305+
return new VPWidenMemoryInstructionRecipe(cast<LoadInst>(Ingredient),
2306+
getAddr(), getMask(), Consecutive,
2307+
Reverse, getDebugLoc());
23062308
}
23072309

23082310
VP_CLASSOF_IMPL(VPDef::VPWidenMemoryInstructionSC)

llvm/lib/Transforms/Vectorize/VPlanTransforms.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ void VPlanTransforms::VPInstructionsToVPRecipes(
6464
if (LoadInst *Load = dyn_cast<LoadInst>(Inst)) {
6565
NewRecipe = new VPWidenMemoryInstructionRecipe(
6666
*Load, Ingredient.getOperand(0), nullptr /*Mask*/,
67-
false /*Consecutive*/, false /*Reverse*/);
67+
false /*Consecutive*/, false /*Reverse*/,
68+
Ingredient.getDebugLoc());
6869
} else if (StoreInst *Store = dyn_cast<StoreInst>(Inst)) {
6970
NewRecipe = new VPWidenMemoryInstructionRecipe(
7071
*Store, Ingredient.getOperand(1), Ingredient.getOperand(0),
71-
nullptr /*Mask*/, false /*Consecutive*/, false /*Reverse*/);
72+
nullptr /*Mask*/, false /*Consecutive*/, false /*Reverse*/,
73+
Ingredient.getDebugLoc());
7274
} else if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(Inst)) {
7375
NewRecipe = new VPWidenGEPRecipe(GEP, Ingredient.operands());
7476
} else if (CallInst *CI = dyn_cast<CallInst>(Inst)) {

llvm/unittests/Transforms/Vectorize/VPlanTest.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ TEST(VPRecipeTest, CastVPWidenMemoryInstructionRecipeToVPUserAndVPDef) {
10361036
new LoadInst(Int32, UndefValue::get(Int32Ptr), "", false, Align(1));
10371037
VPValue Addr;
10381038
VPValue Mask;
1039-
VPWidenMemoryInstructionRecipe Recipe(*Load, &Addr, &Mask, true, false);
1039+
VPWidenMemoryInstructionRecipe Recipe(*Load, &Addr, &Mask, true, false, {});
10401040
EXPECT_TRUE(isa<VPUser>(&Recipe));
10411041
VPRecipeBase *BaseR = &Recipe;
10421042
EXPECT_TRUE(isa<VPUser>(BaseR));
@@ -1131,7 +1131,7 @@ TEST(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
11311131
new LoadInst(Int32, UndefValue::get(Int32Ptr), "", false, Align(1));
11321132
VPValue Addr;
11331133
VPValue Mask;
1134-
VPWidenMemoryInstructionRecipe Recipe(*Load, &Addr, &Mask, true, false);
1134+
VPWidenMemoryInstructionRecipe Recipe(*Load, &Addr, &Mask, true, false, {});
11351135
EXPECT_FALSE(Recipe.mayHaveSideEffects());
11361136
EXPECT_TRUE(Recipe.mayReadFromMemory());
11371137
EXPECT_FALSE(Recipe.mayWriteToMemory());
@@ -1146,7 +1146,7 @@ TEST(VPRecipeTest, MayHaveSideEffectsAndMayReadWriteMemory) {
11461146
VPValue Mask;
11471147
VPValue StoredV;
11481148
VPWidenMemoryInstructionRecipe Recipe(*Store, &Addr, &StoredV, &Mask, false,
1149-
false);
1149+
false, {});
11501150
EXPECT_TRUE(Recipe.mayHaveSideEffects());
11511151
EXPECT_FALSE(Recipe.mayReadFromMemory());
11521152
EXPECT_TRUE(Recipe.mayWriteToMemory());

0 commit comments

Comments
 (0)