Skip to content

Commit 9f37cdc

Browse files
committed
[VPlan] Update VPTransformState accessors to take const VPValue (NFC).
This will enable using const VPValue * pointers are in more places.
1 parent 39edcf9 commit 9f37cdc

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

llvm/lib/Transforms/Vectorize/VPlan.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ VPTransformState::VPTransformState(const TargetTransformInfo *TTI,
223223
CurrentParentLoop(CurrentParentLoop), LVer(nullptr),
224224
TypeAnalysis(CanonicalIVTy) {}
225225

226-
Value *VPTransformState::get(VPValue *Def, const VPLane &Lane) {
226+
Value *VPTransformState::get(const VPValue *Def, const VPLane &Lane) {
227227
if (Def->isLiveIn())
228228
return Def->getLiveInIRValue();
229229

@@ -248,7 +248,7 @@ Value *VPTransformState::get(VPValue *Def, const VPLane &Lane) {
248248
return Extract;
249249
}
250250

251-
Value *VPTransformState::get(VPValue *Def, bool NeedsScalar) {
251+
Value *VPTransformState::get(const VPValue *Def, bool NeedsScalar) {
252252
if (NeedsScalar) {
253253
assert((VF.isScalar() || Def->isLiveIn() || hasVectorValue(Def) ||
254254
!vputils::onlyFirstLaneUsed(Def) ||
@@ -392,7 +392,7 @@ void VPTransformState::setDebugLocFrom(DebugLoc DL) {
392392
Builder.SetCurrentDebugLocation(DIL);
393393
}
394394

395-
void VPTransformState::packScalarIntoVectorizedValue(VPValue *Def,
395+
void VPTransformState::packScalarIntoVectorizedValue(const VPValue *Def,
396396
const VPLane &Lane) {
397397
Value *ScalarInst = get(Def, Lane);
398398
Value *WideValue = get(Def);

llvm/lib/Transforms/Vectorize/VPlanHelpers.h

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -219,21 +219,23 @@ struct VPTransformState {
219219
struct DataState {
220220
// Each value from the original loop, when vectorized, is represented by a
221221
// vector value in the map.
222-
DenseMap<VPValue *, Value *> VPV2Vector;
222+
DenseMap<const VPValue *, Value *> VPV2Vector;
223223

224-
DenseMap<VPValue *, SmallVector<Value *, 4>> VPV2Scalars;
224+
DenseMap<const VPValue *, SmallVector<Value *, 4>> VPV2Scalars;
225225
} Data;
226226

227227
/// Get the generated vector Value for a given VPValue \p Def if \p IsScalar
228228
/// is false, otherwise return the generated scalar. \See set.
229-
Value *get(VPValue *Def, bool IsScalar = false);
229+
Value *get(const VPValue *Def, bool IsScalar = false);
230230

231231
/// Get the generated Value for a given VPValue and given Part and Lane.
232-
Value *get(VPValue *Def, const VPLane &Lane);
232+
Value *get(const VPValue *Def, const VPLane &Lane);
233233

234-
bool hasVectorValue(VPValue *Def) { return Data.VPV2Vector.contains(Def); }
234+
bool hasVectorValue(const VPValue *Def) {
235+
return Data.VPV2Vector.contains(Def);
236+
}
235237

236-
bool hasScalarValue(VPValue *Def, VPLane Lane) {
238+
bool hasScalarValue(const VPValue *Def, VPLane Lane) {
237239
auto I = Data.VPV2Scalars.find(Def);
238240
if (I == Data.VPV2Scalars.end())
239241
return false;
@@ -243,7 +245,7 @@ struct VPTransformState {
243245

244246
/// Set the generated vector Value for a given VPValue, if \p
245247
/// IsScalar is false. If \p IsScalar is true, set the scalar in lane 0.
246-
void set(VPValue *Def, Value *V, bool IsScalar = false) {
248+
void set(const VPValue *Def, Value *V, bool IsScalar = false) {
247249
if (IsScalar) {
248250
set(Def, V, VPLane(0));
249251
return;
@@ -254,13 +256,13 @@ struct VPTransformState {
254256
}
255257

256258
/// Reset an existing vector value for \p Def and a given \p Part.
257-
void reset(VPValue *Def, Value *V) {
259+
void reset(const VPValue *Def, Value *V) {
258260
assert(Data.VPV2Vector.contains(Def) && "need to overwrite existing value");
259261
Data.VPV2Vector[Def] = V;
260262
}
261263

262264
/// Set the generated scalar \p V for \p Def and the given \p Lane.
263-
void set(VPValue *Def, Value *V, const VPLane &Lane) {
265+
void set(const VPValue *Def, Value *V, const VPLane &Lane) {
264266
auto &Scalars = Data.VPV2Scalars[Def];
265267
unsigned CacheIdx = Lane.mapToCacheIndex(VF);
266268
if (Scalars.size() <= CacheIdx)
@@ -270,7 +272,7 @@ struct VPTransformState {
270272
}
271273

272274
/// Reset an existing scalar value for \p Def and a given \p Lane.
273-
void reset(VPValue *Def, Value *V, const VPLane &Lane) {
275+
void reset(const VPValue *Def, Value *V, const VPLane &Lane) {
274276
auto Iter = Data.VPV2Scalars.find(Def);
275277
assert(Iter != Data.VPV2Scalars.end() &&
276278
"need to overwrite existing value");
@@ -299,7 +301,7 @@ struct VPTransformState {
299301

300302
/// Construct the vectorized value of a scalarized value \p V one lane at a
301303
/// time.
302-
void packScalarIntoVectorizedValue(VPValue *Def, const VPLane &Lane);
304+
void packScalarIntoVectorizedValue(const VPValue *Def, const VPLane &Lane);
303305

304306
/// Hold state information used when constructing the CFG of the output IR,
305307
/// traversing the VPBasicBlocks and generating corresponding IR BasicBlocks.

0 commit comments

Comments
 (0)