[llvm] [TableGen] Avoid repeated hash lookups (NFC) (PR #120681)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 20:07:13 PST 2024


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/120681

None

>From b9dde9a9aec923b8141bc2bf72b6bbdf110ebda5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 19 Dec 2024 13:04:46 -0800
Subject: [PATCH] [TableGen] Avoid repeated hash lookups (NFC)

---
 llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
index 1a393beaa14f96..7a82581f2240ce 100644
--- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
+++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp
@@ -3508,9 +3508,8 @@ void CodeGenDAGPatterns::FindPatternInputsAndOutputs(
         Val->getDef()->isSubClassOf("PointerLikeRegClass")) {
       if (Dest->getName().empty())
         I.error("set destination must have a name!");
-      if (InstResults.count(Dest->getName()))
+      if (!InstResults.try_emplace(Dest->getName(), Dest).second)
         I.error("cannot set '" + Dest->getName() + "' multiple times");
-      InstResults[Dest->getName()] = Dest;
     } else if (Val->getDef()->isSubClassOf("Register")) {
       InstImpResults.push_back(Val->getDef());
     } else {



More information about the llvm-commits mailing list