[llvm] [Analysis] Avoid repeated hash lookups (NFC) (PR #126851)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 11 21:01:38 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-analysis
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/126851.diff
1 Files Affected:
- (modified) llvm/include/llvm/Analysis/SparsePropagation.h (+3-3)
``````````diff
diff --git a/llvm/include/llvm/Analysis/SparsePropagation.h b/llvm/include/llvm/Analysis/SparsePropagation.h
index cc79870229873..b85e11942a320 100644
--- a/llvm/include/llvm/Analysis/SparsePropagation.h
+++ b/llvm/include/llvm/Analysis/SparsePropagation.h
@@ -244,13 +244,13 @@ SparseSolver<LatticeKey, LatticeVal, KeyInfo>::getValueState(LatticeKey Key) {
template <class LatticeKey, class LatticeVal, class KeyInfo>
void SparseSolver<LatticeKey, LatticeVal, KeyInfo>::UpdateState(LatticeKey Key,
LatticeVal LV) {
- auto I = ValueState.find(Key);
- if (I != ValueState.end() && I->second == LV)
+ auto [I, Inserted] = ValueState.try_emplace(Key);
+ if (!Inserted && I->second == LV)
return; // No change.
// Update the state of the given LatticeKey and add its corresponding LLVM
// value to the work list.
- ValueState[Key] = std::move(LV);
+ I->second = std::move(LV);
if (Value *V = KeyInfo::getValueFromLatticeKey(Key))
ValueWorkList.push_back(V);
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/126851
More information about the llvm-commits
mailing list