From baa34e215df072f8b1807b20a106d71b69c9cf38 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 9 Mar 2025 00:51:39 -0800 Subject: [PATCH] [CodeGen] Avoid repeated hash lookups (NFC) --- 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 088062afab177..d5fbd4c380746 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