Skip to content

Commit f773efc

Browse files
committed
[VPlan] Add VPIRMetadata parameter to VPInstruction constructor. (NFC)
Update VPInstruction constructor to accept VPIRMetadata between the Flags and DebugLoc parameters. This allows metadata to be passed during construction rather than assigned afterward.
1 parent 04f87c6 commit f773efc

File tree

3 files changed

+28
-18
lines changed

3 files changed

+28
-18
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorizationPlanner.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class VPBuilder {
167167
DebugLoc DL = DebugLoc::getUnknown(),
168168
const Twine &Name = "") {
169169
return tryInsertInstruction(
170-
new VPInstruction(Opcode, Operands, Flags, DL, Name));
170+
new VPInstruction(Opcode, Operands, Flags, {}, DL, Name));
171171
}
172172

173173
VPInstruction *createNaryOp(unsigned Opcode, ArrayRef<VPValue *> Operands,
@@ -184,7 +184,7 @@ class VPBuilder {
184184
DebugLoc DL = DebugLoc::getUnknown(),
185185
const Twine &Name = "") {
186186
return tryInsertInstruction(
187-
new VPInstruction(Opcode, Operands, WrapFlags, DL, Name));
187+
new VPInstruction(Opcode, Operands, WrapFlags, {}, DL, Name));
188188
}
189189

190190
VPInstruction *createNot(VPValue *Operand,
@@ -205,7 +205,7 @@ class VPBuilder {
205205

206206
return tryInsertInstruction(new VPInstruction(
207207
Instruction::BinaryOps::Or, {LHS, RHS},
208-
VPRecipeWithIRFlags::DisjointFlagsTy(false), DL, Name));
208+
VPRecipeWithIRFlags::DisjointFlagsTy(false), {}, DL, Name));
209209
}
210210

211211
VPInstruction *createLogicalAnd(VPValue *LHS, VPValue *RHS,
@@ -221,7 +221,7 @@ class VPBuilder {
221221
std::optional<FastMathFlags> FMFs = std::nullopt) {
222222
auto *Select =
223223
FMFs ? new VPInstruction(Instruction::Select, {Cond, TrueVal, FalseVal},
224-
*FMFs, DL, Name)
224+
*FMFs, {}, DL, Name)
225225
: new VPInstruction(Instruction::Select, {Cond, TrueVal, FalseVal},
226226
DL, Name);
227227
return tryInsertInstruction(Select);
@@ -235,7 +235,7 @@ class VPBuilder {
235235
assert(Pred >= CmpInst::FIRST_ICMP_PREDICATE &&
236236
Pred <= CmpInst::LAST_ICMP_PREDICATE && "invalid predicate");
237237
return tryInsertInstruction(
238-
new VPInstruction(Instruction::ICmp, {A, B}, Pred, DL, Name));
238+
new VPInstruction(Instruction::ICmp, {A, B}, Pred, {}, DL, Name));
239239
}
240240

241241
/// Create a new FCmp VPInstruction with predicate \p Pred and operands \p A
@@ -246,31 +246,31 @@ class VPBuilder {
246246
assert(Pred >= CmpInst::FIRST_FCMP_PREDICATE &&
247247
Pred <= CmpInst::LAST_FCMP_PREDICATE && "invalid predicate");
248248
return tryInsertInstruction(
249-
new VPInstruction(Instruction::FCmp, {A, B}, Pred, DL, Name));
249+
new VPInstruction(Instruction::FCmp, {A, B}, Pred, {}, DL, Name));
250250
}
251251

252252
VPInstruction *createPtrAdd(VPValue *Ptr, VPValue *Offset,
253253
DebugLoc DL = DebugLoc::getUnknown(),
254254
const Twine &Name = "") {
255255
return tryInsertInstruction(
256256
new VPInstruction(VPInstruction::PtrAdd, {Ptr, Offset},
257-
GEPNoWrapFlags::none(), DL, Name));
257+
GEPNoWrapFlags::none(), {}, DL, Name));
258258
}
259259

260260
VPInstruction *createNoWrapPtrAdd(VPValue *Ptr, VPValue *Offset,
261261
GEPNoWrapFlags GEPFlags,
262262
DebugLoc DL = DebugLoc::getUnknown(),
263263
const Twine &Name = "") {
264264
return tryInsertInstruction(new VPInstruction(
265-
VPInstruction::PtrAdd, {Ptr, Offset}, GEPFlags, DL, Name));
265+
VPInstruction::PtrAdd, {Ptr, Offset}, GEPFlags, {}, DL, Name));
266266
}
267267

268268
VPInstruction *createWidePtrAdd(VPValue *Ptr, VPValue *Offset,
269269
DebugLoc DL = DebugLoc::getUnknown(),
270270
const Twine &Name = "") {
271271
return tryInsertInstruction(
272272
new VPInstruction(VPInstruction::WidePtrAdd, {Ptr, Offset},
273-
GEPNoWrapFlags::none(), DL, Name));
273+
GEPNoWrapFlags::none(), {}, DL, Name));
274274
}
275275

276276
VPPhi *createScalarPhi(ArrayRef<VPValue *> IncomingValues, DebugLoc DL,
@@ -303,9 +303,11 @@ class VPBuilder {
303303
}
304304

305305
VPInstruction *createScalarCast(Instruction::CastOps Opcode, VPValue *Op,
306-
Type *ResultTy, DebugLoc DL) {
306+
Type *ResultTy, DebugLoc DL,
307+
const VPIRFlags &Flags = {},
308+
const VPIRMetadata &Metadata = {}) {
307309
return tryInsertInstruction(
308-
new VPInstructionWithType(Opcode, Op, ResultTy, {}, DL));
310+
new VPInstructionWithType(Opcode, Op, ResultTy, DL, Flags, Metadata));
309311
}
310312

311313
VPValue *createScalarZExtOrTrunc(VPValue *Op, Type *ResultTy, Type *SrcTy,

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,14 +1107,15 @@ class LLVM_ABI_FOR_TEST VPInstruction : public VPRecipeWithIRFlags,
11071107
VPIRMetadata(), Opcode(Opcode), Name(Name.str()) {}
11081108

11091109
VPInstruction(unsigned Opcode, ArrayRef<VPValue *> Operands,
1110-
const VPIRFlags &Flags, DebugLoc DL = DebugLoc::getUnknown(),
1111-
const Twine &Name = "");
1110+
const VPIRFlags &Flags, const VPIRMetadata &MD = {},
1111+
DebugLoc DL = DebugLoc::getUnknown(), const Twine &Name = "");
11121112

11131113
VP_CLASSOF_IMPL(VPDef::VPInstructionSC)
11141114

11151115
VPInstruction *clone() override {
11161116
SmallVector<VPValue *, 2> Operands(operands());
1117-
auto *New = new VPInstruction(Opcode, Operands, *this, getDebugLoc(), Name);
1117+
auto *New =
1118+
new VPInstruction(Opcode, Operands, *this, *this, getDebugLoc(), Name);
11181119
if (getUnderlyingValue())
11191120
New->setUnderlyingValue(getUnderlyingInstr());
11201121
return New;
@@ -1196,7 +1197,14 @@ class VPInstructionWithType : public VPInstruction {
11961197
VPInstructionWithType(unsigned Opcode, ArrayRef<VPValue *> Operands,
11971198
Type *ResultTy, const VPIRFlags &Flags, DebugLoc DL,
11981199
const Twine &Name = "")
1199-
: VPInstruction(Opcode, Operands, Flags, DL, Name), ResultTy(ResultTy) {}
1200+
: VPInstruction(Opcode, Operands, Flags, {}, DL, Name),
1201+
ResultTy(ResultTy) {}
1202+
1203+
VPInstructionWithType(unsigned Opcode, ArrayRef<VPValue *> Operands,
1204+
Type *ResultTy, DebugLoc DL, const VPIRFlags &Flags,
1205+
const VPIRMetadata &Metadata, const Twine &Name = "")
1206+
: VPInstruction(Opcode, Operands, Flags, Metadata, DL, Name),
1207+
ResultTy(ResultTy) {}
12001208

12011209
static inline bool classof(const VPRecipeBase *R) {
12021210
// VPInstructionWithType are VPInstructions with specific opcodes requiring

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,10 +490,10 @@ template class VPUnrollPartAccessor<3>;
490490
}
491491

492492
VPInstruction::VPInstruction(unsigned Opcode, ArrayRef<VPValue *> Operands,
493-
const VPIRFlags &Flags, DebugLoc DL,
494-
const Twine &Name)
493+
const VPIRFlags &Flags, const VPIRMetadata &MD,
494+
DebugLoc DL, const Twine &Name)
495495
: VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, Flags, DL),
496-
VPIRMetadata(), Opcode(Opcode), Name(Name.str()) {
496+
VPIRMetadata(MD), Opcode(Opcode), Name(Name.str()) {
497497
assert(flagsValidForOpcode(getOpcode()) &&
498498
"Set flags not supported for the provided opcode");
499499
assert((getNumOperandsForOpcode(Opcode) == -1u ||

0 commit comments

Comments
 (0)