Skip to content

Commit 2bbb394

Browse files
[CodeGen] Avoid repeated hash lookups (NFC) (llvm#129418)
1 parent 69c7336 commit 2bbb394

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2054,17 +2054,17 @@ bool AssignmentTrackingLowering::join(
20542054
// Exactly one visited pred. Copy the LiveOut from that pred into BB LiveIn.
20552055
if (VisitedPreds.size() == 1) {
20562056
const BlockInfo &PredLiveOut = LiveOut.find(VisitedPreds[0])->second;
2057-
auto CurrentLiveInEntry = LiveIn.find(&BB);
20582057

20592058
// Check if there isn't an entry, or there is but the LiveIn set has
20602059
// changed (expensive check).
2061-
if (CurrentLiveInEntry == LiveIn.end())
2062-
LiveIn.insert(std::make_pair(&BB, PredLiveOut));
2063-
else if (PredLiveOut != CurrentLiveInEntry->second)
2060+
auto [CurrentLiveInEntry, Inserted] = LiveIn.try_emplace(&BB, PredLiveOut);
2061+
if (Inserted)
2062+
return /*Changed*/ true;
2063+
if (PredLiveOut != CurrentLiveInEntry->second) {
20642064
CurrentLiveInEntry->second = PredLiveOut;
2065-
else
2066-
return /*Changed*/ false;
2067-
return /*Changed*/ true;
2065+
return /*Changed*/ true;
2066+
}
2067+
return /*Changed*/ false;
20682068
}
20692069

20702070
// More than one pred. Join LiveOuts of blocks 1 and 2.

0 commit comments

Comments
 (0)