[llvm] [GVNSink] Avoid repeated hash lookups (NFC) (PR #113023)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 18 22:14:48 PDT 2024
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/113023.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Scalar/GVNSink.cpp (+3-3)
``````````diff
diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index 3dfa2dd9df27f5..42b44725240f29 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -535,12 +535,12 @@ class ValueTable {
uint32_t e = ExpressionNumbering[exp];
if (!e) {
hash_code H = exp->getHashValue([=](Value *V) { return lookupOrAdd(V); });
- auto I = HashNumbering.find(H);
- if (I != HashNumbering.end()) {
+ auto [I, Inserted] = HashNumbering.try_emplace(H);
+ if (!Inserted) {
e = I->second;
} else {
e = nextValueNumber++;
- HashNumbering[H] = e;
+ I->second = e;
ExpressionNumbering[exp] = e;
}
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/113023
More information about the llvm-commits
mailing list