Skip to content

Commit

Permalink
[LV] Use SmallVector::resize instead of push_back/emplace_back in a l…
Browse files Browse the repository at this point in the history
…oop. NFC (llvm#83696)

This should be more efficient since the vector can know how much
additional space to reserve before creating the new elements.
  • Loading branch information
topperc authored Mar 4, 2024
1 parent 379e55e commit ac783ad
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions llvm/lib/Transforms/Vectorize/VPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,12 @@ struct VPTransformState {
void set(VPValue *Def, Value *V, const VPIteration &Instance) {
auto Iter = Data.PerPartScalars.insert({Def, {}});
auto &PerPartVec = Iter.first->second;
while (PerPartVec.size() <= Instance.Part)
PerPartVec.emplace_back();
if (PerPartVec.size() <= Instance.Part)
PerPartVec.resize(Instance.Part + 1);
auto &Scalars = PerPartVec[Instance.Part];
unsigned CacheIdx = Instance.Lane.mapToCacheIndex(VF);
while (Scalars.size() <= CacheIdx)
Scalars.push_back(nullptr);
if (Scalars.size() <= CacheIdx)
Scalars.resize(CacheIdx + 1);
assert(!Scalars[CacheIdx] && "should overwrite existing value");
Scalars[CacheIdx] = V;
}
Expand Down

0 comments on commit ac783ad

Please sign in to comment.