Skip to content

Commit 042e860

Browse files
[Vectorize] Avoid repeated hash lookups (NFC) (#126681)
1 parent c9686d6 commit 042e860

File tree

1 file changed

+5
-7
lines changed
  • llvm/lib/Transforms/Vectorize

1 file changed

+5
-7
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3709,18 +3709,16 @@ class VPlan {
37093709
/// yet) for \p V.
37103710
VPValue *getOrAddLiveIn(Value *V) {
37113711
assert(V && "Trying to get or add the VPValue of a null Value");
3712-
if (!Value2VPValue.count(V)) {
3712+
auto [It, Inserted] = Value2VPValue.try_emplace(V);
3713+
if (Inserted) {
37133714
VPValue *VPV = new VPValue(V);
37143715
VPLiveInsToFree.push_back(VPV);
37153716
assert(VPV->isLiveIn() && "VPV must be a live-in.");
3716-
assert(!Value2VPValue.count(V) && "Value already exists in VPlan");
3717-
Value2VPValue[V] = VPV;
3717+
It->second = VPV;
37183718
}
37193719

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

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

0 commit comments

Comments
 (0)