[llvm] f30ff0b - [TableGen] Avoid repeated hash lookups (NFC) (#123161)

via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 15 23:07:15 PST 2025


Author: Kazu Hirata
Date: 2025-01-15T23:07:12-08:00
New Revision: f30ff0b1a978a49cb0f9bf069b7e949c985515b0

URL: https://github.com/llvm/llvm-project/commit/f30ff0b1a978a49cb0f9bf069b7e949c985515b0
DIFF: https://github.com/llvm/llvm-project/commit/f30ff0b1a978a49cb0f9bf069b7e949c985515b0.diff

LOG: [TableGen] Avoid repeated hash lookups (NFC) (#123161)

Added: 
    

Modified: 
    llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
index a81f2b53f2846e..d56623ed60b36d 100644
--- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
+++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp
@@ -875,10 +875,8 @@ unsigned RuleMatcher::getInsnVarID(InstructionMatcher &InsnMatcher) const {
 }
 
 void RuleMatcher::defineOperand(StringRef SymbolicName, OperandMatcher &OM) {
-  if (!DefinedOperands.contains(SymbolicName)) {
-    DefinedOperands[SymbolicName] = &OM;
+  if (DefinedOperands.try_emplace(SymbolicName, &OM).second)
     return;
-  }
 
   // If the operand is already defined, then we must ensure both references in
   // the matcher have the exact same node.
@@ -889,8 +887,7 @@ void RuleMatcher::defineOperand(StringRef SymbolicName, OperandMatcher &OM) {
 }
 
 void RuleMatcher::definePhysRegOperand(const Record *Reg, OperandMatcher &OM) {
-  if (!PhysRegOperands.contains(Reg))
-    PhysRegOperands[Reg] = &OM;
+  PhysRegOperands.try_emplace(Reg, &OM);
 }
 
 InstructionMatcher &


        


More information about the llvm-commits mailing list