[llvm] 2f2295c - [Analysis] Avoid repeated hash lookups (NFC) (#127743)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 19 08:19:53 PST 2025
Author: Kazu Hirata
Date: 2025-02-19T08:19:49-08:00
New Revision: 2f2295cfae971a9564a3ba25b5c2338cfb36f154
URL: https://github.com/llvm/llvm-project/commit/2f2295cfae971a9564a3ba25b5c2338cfb36f154
DIFF: https://github.com/llvm/llvm-project/commit/2f2295cfae971a9564a3ba25b5c2338cfb36f154.diff
LOG: [Analysis] Avoid repeated hash lookups (NFC) (#127743)
Added:
Modified:
llvm/lib/Analysis/AssumeBundleQueries.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/AssumeBundleQueries.cpp b/llvm/lib/Analysis/AssumeBundleQueries.cpp
index 21530693c5f18..c27bfa6f3cc2c 100644
--- a/llvm/lib/Analysis/AssumeBundleQueries.cpp
+++ b/llvm/lib/Analysis/AssumeBundleQueries.cpp
@@ -85,13 +85,14 @@ void llvm::fillMapFromAssume(AssumeInst &Assume, RetainedKnowledgeMap &Result) {
if (!CI)
continue;
uint64_t Val = CI->getZExtValue();
- auto Lookup = Result.find(Key);
- if (Lookup == Result.end() || !Lookup->second.count(&Assume)) {
- Result[Key][&Assume] = {Val, Val};
+ auto [It, Inserted] = Result[Key].try_emplace(&Assume);
+ if (Inserted) {
+ It->second = {Val, Val};
continue;
}
- Lookup->second[&Assume].Min = std::min(Val, Lookup->second[&Assume].Min);
- Lookup->second[&Assume].Max = std::max(Val, Lookup->second[&Assume].Max);
+ auto &MinMax = It->second;
+ MinMax.Min = std::min(Val, MinMax.Min);
+ MinMax.Max = std::max(Val, MinMax.Max);
}
}
More information about the llvm-commits
mailing list