[llvm] [MCA] Avoid repeated hash lookups (NFC) (PR #129192)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 21:43:20 PST 2025


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

None

>From b9a5cf9e253d5591c7e225e68a962cd3db83e6c0 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 27 Feb 2025 01:53:22 -0800
Subject: [PATCH] [MCA] Avoid repeated hash lookups (NFC)

---
 llvm/lib/MCA/InstrBuilder.cpp | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/MCA/InstrBuilder.cpp b/llvm/lib/MCA/InstrBuilder.cpp
index 2cb1908695308..2bac99b6309af 100644
--- a/llvm/lib/MCA/InstrBuilder.cpp
+++ b/llvm/lib/MCA/InstrBuilder.cpp
@@ -634,16 +634,14 @@ InstrBuilder::createInstrDescImpl(const MCInst &MCI,
   bool IsVariadic = MCDesc.isVariadic();
   if ((ID->IsRecyclable = !IsVariadic && !IsVariant)) {
     auto DKey = std::make_pair(MCI.getOpcode(), SchedClassID);
-    Descriptors[DKey] = std::move(ID);
-    return *Descriptors[DKey];
+    return *(Descriptors[DKey] = std::move(ID));
   }
 
   auto VDKey = std::make_pair(hashMCInst(MCI), SchedClassID);
   assert(
       !VariantDescriptors.contains(VDKey) &&
       "Expected VariantDescriptors to not already have a value for this key.");
-  VariantDescriptors[VDKey] = std::move(ID);
-  return *VariantDescriptors[VDKey];
+  return *(VariantDescriptors[VDKey] = std::move(ID));
 }
 
 Expected<const InstrDesc &>



More information about the llvm-commits mailing list