[llvm] [TableGen] Avoid repeated hash lookups (NFC) (PR #107669)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 6 23:35:43 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/107669
None
>From 3fab205e7f174f47b5a30ef59ea50c7f0b7a7234 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Fri, 6 Sep 2024 14:06:07 -0700
Subject: [PATCH] [TableGen] Avoid repeated hash lookups (NFC)
---
llvm/utils/TableGen/GlobalISelCombinerEmitter.cpp | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
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