Skip to content

[Vectorize] Avoid repeated hash lookups (NFC) #126681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions llvm/lib/Transforms/Vectorize/VPlan.h
Original file line number Diff line number Diff line change
Expand Up @@ -3709,18 +3709,16 @@ class VPlan {
/// yet) for \p V.
VPValue *getOrAddLiveIn(Value *V) {
assert(V && "Trying to get or add the VPValue of a null Value");
if (!Value2VPValue.count(V)) {
auto [It, Inserted] = Value2VPValue.try_emplace(V);
if (Inserted) {
VPValue *VPV = new VPValue(V);
VPLiveInsToFree.push_back(VPV);
assert(VPV->isLiveIn() && "VPV must be a live-in.");
assert(!Value2VPValue.count(V) && "Value already exists in VPlan");
Value2VPValue[V] = VPV;
It->second = VPV;
}

assert(Value2VPValue.count(V) && "Value does not exist in VPlan");
assert(Value2VPValue[V]->isLiveIn() &&
"Only live-ins should be in mapping");
return Value2VPValue[V];
assert(It->second->isLiveIn() && "Only live-ins should be in mapping");
return It->second;
}

/// Return the live-in VPValue for \p V, if there is one or nullptr otherwise.
Expand Down