[llvm] 4b676e1 - [TableGen] Avoid repeated hash lookups (NFC) (#107669)

via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 7 08:22:13 PDT 2024


Author: Kazu Hirata
Date: 2024-09-07T08:22:08-07:00
New Revision: 4b676e17d9f0e7e5cc3c8f9158a69174675a60f2

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

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

Added: 
    

Modified: 
    llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
index 0f8f1cce817002..b97b87e2117507 100644
--- a/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
+++ b/llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp
@@ -1696,9 +1696,8 @@ bool CombineRuleBuilder::emitPatFragMatchPattern(
     DenseSet<const Pattern *> &SeenPats) {
   auto StackTrace = PrettyStackTraceEmit(RuleDef, &PFP);
 
-  if (SeenPats.contains(&PFP))
+  if (!SeenPats.insert(&PFP).second)
     return true;
-  SeenPats.insert(&PFP);
 
   const auto &PF = PFP.getPatFrag();
 
@@ -1919,11 +1918,9 @@ bool CombineRuleBuilder::emitInstructionApplyPattern(
     StringMap<unsigned> &OperandToTempRegID) {
   auto StackTrace = PrettyStackTraceEmit(RuleDef, &P);
 
-  if (SeenPats.contains(&P))
+  if (!SeenPats.insert(&P).second)
     return true;
 
-  SeenPats.insert(&P);
-
   // First, render the uses.
   for (auto &Op : P.named_operands()) {
     if (Op.isDef())
@@ -2188,11 +2185,9 @@ bool CombineRuleBuilder::emitCodeGenInstructionMatchPattern(
     OperandMapperFnRef OperandMapper) {
   auto StackTrace = PrettyStackTraceEmit(RuleDef, &P);
 
-  if (SeenPats.contains(&P))
+  if (!SeenPats.insert(&P).second)
     return true;
 
-  SeenPats.insert(&P);
-
   IM.addPredicate<InstructionOpcodeMatcher>(&P.getInst());
   declareInstExpansion(CE, IM, P.getName());
 


        


More information about the llvm-commits mailing list