[llvm] [Utils] Avoid repeated hash lookups (NFC) (PR #129990)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 5 21:57:16 PST 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/129990.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Utils/SimplifyCFG.cpp (+3-2)
``````````diff
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index c71605c500686..eb03689f31949 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -5833,9 +5833,10 @@ static bool eliminateDeadSwitchCases(SwitchInst *SI, DomTreeUpdater *DTU,
for (const auto &Case : SI->cases()) {
auto *Successor = Case.getCaseSuccessor();
if (DTU) {
- if (!NumPerSuccessorCases.count(Successor))
+ auto [It, Inserted] = NumPerSuccessorCases.try_emplace(Successor);
+ if (Inserted)
UniqueSuccessors.push_back(Successor);
- ++NumPerSuccessorCases[Successor];
+ ++It->second;
}
const APInt &CaseVal = Case.getCaseValue()->getValue();
if (Known.Zero.intersects(CaseVal) || !Known.One.isSubsetOf(CaseVal) ||
``````````
</details>
https://github.com/llvm/llvm-project/pull/129990
More information about the llvm-commits
mailing list