aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/CodeGenPrepare.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2025-03-09 23:15:32 -0700
committerGitHub <noreply@github.com>2025-03-09 23:15:32 -0700
commitb2b267ea7a3b85f83977cc74ba79332e453aed82 (patch)
treee26290f52cbb4f4cd43a81dcf9aae687c242025d /llvm/lib/CodeGen/CodeGenPrepare.cpp
parent5addbf0c60bf941b081726c4a6a9641ec9bf425f (diff)
downloadllvm-b2b267ea7a3b85f83977cc74ba79332e453aed82.zip
llvm-b2b267ea7a3b85f83977cc74ba79332e453aed82.tar.gz
llvm-b2b267ea7a3b85f83977cc74ba79332e453aed82.tar.bz2
[CodeGen] Avoid repeated hash lookups (NFC) (#130543)
Diffstat (limited to 'llvm/lib/CodeGen/CodeGenPrepare.cpp')
-rw-r--r--llvm/lib/CodeGen/CodeGenPrepare.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 088062afa..d5fbd4c 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -4672,8 +4672,8 @@ class TypePromotionHelper {
static void addPromotedInst(InstrToOrigTy &PromotedInsts,
Instruction *ExtOpnd, bool IsSExt) {
ExtType ExtTy = IsSExt ? SignExtension : ZeroExtension;
- InstrToOrigTy::iterator It = PromotedInsts.find(ExtOpnd);
- if (It != PromotedInsts.end()) {
+ auto [It, Inserted] = PromotedInsts.try_emplace(ExtOpnd);
+ if (!Inserted) {
// If the new extension is same as original, the information in
// PromotedInsts[ExtOpnd] is still correct.
if (It->second.getInt() == ExtTy)
@@ -4684,7 +4684,7 @@ class TypePromotionHelper {
// BothExtension.
ExtTy = BothExtension;
}
- PromotedInsts[ExtOpnd] = TypeIsSExt(ExtOpnd->getType(), ExtTy);
+ It->second = TypeIsSExt(ExtOpnd->getType(), ExtTy);
}
/// Utility function to query the original type of instruction \p Opnd