Skip to content

Commit e42e526

Browse files
committed
[VPlan] Make VPWidenMemoryInstructionRecipe a VPDef.
This patch updates VPWidenMemoryInstructionRecipe to use VPDef to manage the value it produces instead of inheriting from VPValue. Reviewed By: gilr Differential Revision: https://reviews.llvm.org/D90563
1 parent aabaca3 commit e42e526

File tree

4 files changed

+28
-18
lines changed

4 files changed

+28
-18
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8827,11 +8827,10 @@ void VPPredInstPHIRecipe::execute(VPTransformState &State) {
88278827
}
88288828

88298829
void VPWidenMemoryInstructionRecipe::execute(VPTransformState &State) {
8830-
Instruction *Instr = getUnderlyingInstr();
8831-
VPValue *StoredValue = isa<StoreInst>(Instr) ? getStoredValue() : nullptr;
8832-
State.ILV->vectorizeMemoryInstruction(Instr, State,
8833-
StoredValue ? nullptr : this, getAddr(),
8834-
StoredValue, getMask());
8830+
VPValue *StoredValue = isStore() ? getStoredValue() : nullptr;
8831+
State.ILV->vectorizeMemoryInstruction(&Ingredient, State,
8832+
StoredValue ? nullptr : toVPValue(),
8833+
getAddr(), StoredValue, getMask());
88358834
}
88368835

88378836
// Determine how to lower the scalar epilogue, which depends on 1) optimising

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,12 @@ VPValue *VPRecipeBase::toVPValue() {
124124
return V;
125125
if (auto *V = dyn_cast<VPReductionRecipe>(this))
126126
return V;
127-
if (auto *V = dyn_cast<VPWidenMemoryInstructionRecipe>(this))
128-
return V;
127+
if (auto *V = dyn_cast<VPWidenMemoryInstructionRecipe>(this)) {
128+
if (!V->isStore())
129+
return V->getVPValue();
130+
else
131+
return nullptr;
132+
}
129133
if (auto *V = dyn_cast<VPWidenCallRecipe>(this))
130134
return V;
131135
if (auto *V = dyn_cast<VPWidenSelectRecipe>(this))
@@ -144,8 +148,12 @@ const VPValue *VPRecipeBase::toVPValue() const {
144148
return V;
145149
if (auto *V = dyn_cast<VPReductionRecipe>(this))
146150
return V;
147-
if (auto *V = dyn_cast<VPWidenMemoryInstructionRecipe>(this))
148-
return V;
151+
if (auto *V = dyn_cast<VPWidenMemoryInstructionRecipe>(this)) {
152+
if (!V->isStore())
153+
return V->getVPValue();
154+
else
155+
return nullptr;
156+
}
149157
if (auto *V = dyn_cast<VPWidenCallRecipe>(this))
150158
return V;
151159
if (auto *V = dyn_cast<VPWidenSelectRecipe>(this))
@@ -993,10 +1001,10 @@ void VPWidenMemoryInstructionRecipe::print(raw_ostream &O, const Twine &Indent,
9931001
O << "\"WIDEN ";
9941002

9951003
if (!isStore()) {
996-
printAsOperand(O, SlotTracker);
1004+
getVPValue()->printAsOperand(O, SlotTracker);
9971005
O << " = ";
9981006
}
999-
O << Instruction::getOpcodeName(getUnderlyingInstr()->getOpcode()) << " ";
1007+
O << Instruction::getOpcodeName(Ingredient.getOpcode()) << " ";
10001008

10011009
printOperands(O, SlotTracker);
10021010
}

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,8 +1265,9 @@ class VPPredInstPHIRecipe : public VPRecipeBase, public VPUser {
12651265
/// TODO: We currently execute only per-part unless a specific instance is
12661266
/// provided.
12671267
class VPWidenMemoryInstructionRecipe : public VPRecipeBase,
1268-
public VPValue,
1268+
public VPDef,
12691269
public VPUser {
1270+
Instruction &Ingredient;
12701271

12711272
void setMask(VPValue *Mask) {
12721273
if (!Mask)
@@ -1280,16 +1281,16 @@ class VPWidenMemoryInstructionRecipe : public VPRecipeBase,
12801281

12811282
public:
12821283
VPWidenMemoryInstructionRecipe(LoadInst &Load, VPValue *Addr, VPValue *Mask)
1283-
: VPRecipeBase(VPWidenMemoryInstructionSC),
1284-
VPValue(VPValue::VPVMemoryInstructionSC, &Load), VPUser({Addr}) {
1284+
: VPRecipeBase(VPWidenMemoryInstructionSC), VPUser({Addr}),
1285+
Ingredient(Load) {
1286+
new VPValue(VPValue::VPVMemoryInstructionSC, &Load, this);
12851287
setMask(Mask);
12861288
}
12871289

12881290
VPWidenMemoryInstructionRecipe(StoreInst &Store, VPValue *Addr,
12891291
VPValue *StoredValue, VPValue *Mask)
1290-
: VPRecipeBase(VPWidenMemoryInstructionSC),
1291-
VPValue(VPValue::VPVMemoryInstructionSC, &Store),
1292-
VPUser({Addr, StoredValue}) {
1292+
: VPRecipeBase(VPWidenMemoryInstructionSC), VPUser({Addr, StoredValue}),
1293+
Ingredient(Store) {
12931294
setMask(Mask);
12941295
}
12951296

@@ -1311,7 +1312,7 @@ class VPWidenMemoryInstructionRecipe : public VPRecipeBase,
13111312
}
13121313

13131314
/// Returns true if this recipe is a store.
1314-
bool isStore() const { return isa<StoreInst>(getUnderlyingInstr()); }
1315+
bool isStore() const { return isa<StoreInst>(Ingredient); }
13151316

13161317
/// Return the address accessed by this recipe.
13171318
VPValue *getStoredValue() const {

llvm/lib/Transforms/Vectorize/VPlanValue.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ class VPSlotTracker;
3636
class VPUser;
3737
class VPRecipeBase;
3838
class VPPredInstPHIRecipe;
39+
class VPWidenMemoryInstructionRecipe;
3940

4041
// This is the base class of the VPlan Def/Use graph, used for modeling the data
4142
// flow into, within and out of the VPlan. VPValues can stand for live-ins
@@ -50,6 +51,7 @@ class VPValue {
5051
friend class VPSlotTracker;
5152
friend class VPRecipeBase;
5253
friend class VPPredInstPHIRecipe;
54+
friend class VPWidenMemoryInstructionRecipe;
5355

5456
const unsigned char SubclassID; ///< Subclass identifier (for isa/dyn_cast).
5557

0 commit comments

Comments
 (0)