From b2b267ea7a3b85f83977cc74ba79332e453aed82 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 9 Mar 2025 23:15:32 -0700 Subject: [PATCH] [CodeGen] Avoid repeated hash lookups (NFC) (#130543) --- llvm/lib/CodeGen/CodeGenPrepare.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp index 088062afab17..d5fbd4c38074 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