[llvm] [CodeGen] Avoid repeated hash lookups (NFC) (PR #131067)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 12 20:55:39 PDT 2025


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

None

>From c5e53e659efb11db4365ed71f751b5f8da6758a7 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Wed, 12 Mar 2025 09:04:13 -0700
Subject: [PATCH] [CodeGen] Avoid repeated hash lookups (NFC)

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

diff --git a/llvm/lib/CodeGen/RDFLiveness.cpp b/llvm/lib/CodeGen/RDFLiveness.cpp
index 682d316a5bfac..e4e21bb55bd58 100644
--- a/llvm/lib/CodeGen/RDFLiveness.cpp
+++ b/llvm/lib/CodeGen/RDFLiveness.cpp
@@ -687,10 +687,8 @@ void Liveness::computePhiInfo() {
 
         if (MidDefs.hasCoverOf(UR))
           continue;
-        if (Subs.find(MidDefs) == Subs.end()) {
-          Subs.insert({MidDefs, SubMap(1, RefHash(), RefEqual(PRI))});
-        }
-        SubMap &SM = Subs.at(MidDefs);
+        SubMap &SM = Subs.try_emplace(MidDefs, 1, RefHash(), RefEqual(PRI))
+                         .first->second;
 
         // General algorithm:
         //   for each (R,U) : U is use node of R, U is reached by PA



More information about the llvm-commits mailing list