-
Notifications
You must be signed in to change notification settings - Fork 11.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VPlan] Only store single vector per VPValue in VPTransformState. (NFC)
After 8ec4067 (#95842), VPTransformState only stores a single vector value per VPValue. Simplify the code by replacing the SmallVector in PerPartOutput with a single Value * and rename to VPV2Vector for clarity. Also remove the redundant Part argument from various accessors.
- Loading branch information
Showing
4 changed files
with
145 additions
and
162 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -263,30 +263,22 @@ struct VPTransformState { | |
std::optional<VPIteration> Instance; | ||
|
||
struct DataState { | ||
/// A type for vectorized values in the new loop. Each value from the | ||
/// original loop, when vectorized, is represented by UF vector values in | ||
/// the new unrolled loop, where UF is the unroll factor. | ||
typedef SmallVector<Value *, 2> PerPartValuesTy; | ||
|
||
DenseMap<VPValue *, PerPartValuesTy> PerPartOutput; | ||
// Each value from the original loop, when vectorized, is represented by a | ||
// vector value in the map. | ||
DenseMap<VPValue *, Value *> VPV2Vector; | ||
|
||
using ScalarsPerPartValuesTy = SmallVector<SmallVector<Value *, 4>, 2>; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
fhahn
Author
Contributor
|
||
DenseMap<VPValue *, ScalarsPerPartValuesTy> PerPartScalars; | ||
} Data; | ||
|
||
/// Get the generated vector Value for a given VPValue \p Def and a given \p | ||
/// Part if \p IsScalar is false, otherwise return the generated scalar | ||
/// for \p Part. \See set. | ||
Value *get(VPValue *Def, unsigned Part, bool IsScalar = false); | ||
/// Get the generated vector Value for a given VPValue \p Def if \p IsScalar | ||
/// is false, otherwise return the generated scalar. \See set. | ||
Value *get(VPValue *Def, bool IsScalar = false); | ||
|
||
/// Get the generated Value for a given VPValue and given Part and Lane. | ||
Value *get(VPValue *Def, const VPIteration &Instance); | ||
|
||
bool hasVectorValue(VPValue *Def, unsigned Part) { | ||
auto I = Data.PerPartOutput.find(Def); | ||
return I != Data.PerPartOutput.end() && Part < I->second.size() && | ||
I->second[Part]; | ||
} | ||
bool hasVectorValue(VPValue *Def) { return Data.VPV2Vector.contains(Def); } | ||
|
||
bool hasScalarValue(VPValue *Def, VPIteration Instance) { | ||
auto I = Data.PerPartScalars.find(Def); | ||
|
@@ -298,28 +290,22 @@ struct VPTransformState { | |
I->second[Instance.Part][CacheIdx]; | ||
} | ||
|
||
/// Set the generated vector Value for a given VPValue and a given Part, if \p | ||
/// IsScalar is false. If \p IsScalar is true, set the scalar in (Part, 0). | ||
void set(VPValue *Def, Value *V, unsigned Part, bool IsScalar = false) { | ||
/// Set the generated vector Value for a given VPValue, if \p | ||
/// IsScalar is false. If \p IsScalar is true, set the scalar in lane 0. | ||
void set(VPValue *Def, Value *V, bool IsScalar = false) { | ||
if (IsScalar) { | ||
set(Def, V, VPIteration(Part, 0)); | ||
set(Def, V, VPIteration(0, 0)); | ||
return; | ||
} | ||
assert((VF.isScalar() || V->getType()->isVectorTy()) && | ||
"scalar values must be stored as (Part, 0)"); | ||
if (!Data.PerPartOutput.count(Def)) { | ||
DataState::PerPartValuesTy Entry(1); | ||
Data.PerPartOutput[Def] = Entry; | ||
} | ||
Data.PerPartOutput[Def][Part] = V; | ||
"scalar values must be stored as (0, 0)"); | ||
Data.VPV2Vector[Def] = V; | ||
} | ||
|
||
/// Reset an existing vector value for \p Def and a given \p Part. | ||
void reset(VPValue *Def, Value *V, unsigned Part) { | ||
auto Iter = Data.PerPartOutput.find(Def); | ||
assert(Iter != Data.PerPartOutput.end() && | ||
"need to overwrite existing value"); | ||
Iter->second[Part] = V; | ||
void reset(VPValue *Def, Value *V) { | ||
assert(Data.VPV2Vector.contains(Def) && "need to overwrite existing value"); | ||
Data.VPV2Vector[Def] = V; | ||
} | ||
|
||
/// Set the generated scalar \p V for \p Def and the given \p Instance. | ||
|
Oops, something went wrong.
PerPart should be reduced here as well.