[llvm] [GVNSink] Avoid repeated hash lookups (NFC) (PR #113023)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 19 15:31:32 PDT 2024
================
@@ -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 + 1);
----------------
nikic wrote:
Shouldn't this be?
```suggestion
auto [I, Inserted] = HashNumbering.try_emplace(H, nextValueNumber);
```
The old code is using the result of post-inc, which is the pre-increment value.
https://github.com/llvm/llvm-project/pull/113023
More information about the llvm-commits
mailing list