[llvm] [Scalar] Avoid repeated hash lookups (NFC) (PR #168217)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 15 09:40:38 PST 2025


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

None

>From 3c7d056e599f8bccd9a8bd9032aae0c2b81e1101 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 15 Nov 2025 00:08:03 -0800
Subject: [PATCH] [Scalar] Avoid repeated hash lookups (NFC)

---
 llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp b/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
index a62804d3ef201..e5399bdd767e2 100644
--- a/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
+++ b/llvm/lib/Transforms/Scalar/StraightLineStrengthReduce.cpp
@@ -1275,8 +1275,7 @@ bool StraightLineStrengthReduce::runOnFunction(Function &F) {
   // Build the dependency graph and sort candidate instructions from dependency
   // roots to leaves
   for (auto &C : Candidates) {
-    if (DependencyGraph.find(C.Ins) == DependencyGraph.end())
-      DependencyGraph[C.Ins] = {};
+    DependencyGraph.try_emplace(C.Ins);
     addDependency(C, C.Basis);
   }
   sortCandidateInstructions();



More information about the llvm-commits mailing list