[llvm] [GVNSink] Avoid repeated hash lookups (NFC) (PR #113023)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 19 14:54:47 PDT 2024
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/113023
>From 01377c73c45c05519d3bba16c14c10b5e08e3dc3 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 18 Oct 2024 09:36:53 -0700
Subject: [PATCH] [GVNSink] Avoid repeated hash lookups (NFC)
---
llvm/lib/Transforms/Scalar/GVNSink.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
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;
}
}
More information about the llvm-commits
mailing list