[llvm] b9cb9b3 - [GVNSink] Avoid repeated hash lookups (NFC) (#113023)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 20 10:41:10 PDT 2024
Author: Kazu Hirata
Date: 2024-10-20T10:41:07-07:00
New Revision: b9cb9b3f0d1e891b385eb53f8414b29554fd9234
URL: https://github.com/llvm/llvm-project/commit/b9cb9b3f0d1e891b385eb53f8414b29554fd9234
DIFF: https://github.com/llvm/llvm-project/commit/b9cb9b3f0d1e891b385eb53f8414b29554fd9234.diff
LOG: [GVNSink] Avoid repeated hash lookups (NFC) (#113023)
Added:
Modified:
llvm/lib/Transforms/Scalar/GVNSink.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Scalar/GVNSink.cpp b/llvm/lib/Transforms/Scalar/GVNSink.cpp
index 3dfa2dd9df27f5..59dfe33d8003ec 100644
--- a/llvm/lib/Transforms/Scalar/GVNSink.cpp
+++ b/llvm/lib/Transforms/Scalar/GVNSink.cpp
@@ -535,14 +535,10 @@ 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()) {
- e = I->second;
- } else {
- e = nextValueNumber++;
- HashNumbering[H] = e;
- ExpressionNumbering[exp] = e;
- }
+ auto [I, Inserted] = HashNumbering.try_emplace(H, nextValueNumber);
+ e = I->second;
+ if (Inserted)
+ ExpressionNumbering[exp] = nextValueNumber++;
}
ValueNumbering[V] = e;
return e;
More information about the llvm-commits
mailing list