[llvm] [Local] Avoid repeated map lookups (NFC) (PR #113072)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 19 20:59:42 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/113072
None
>From 6177955d90e1d6452352583f922fb99864b84b72 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 19 Oct 2024 18:12:31 -0700
Subject: [PATCH] [Local] Avoid repeated map lookups (NFC)
---
llvm/lib/Transforms/Utils/Local.cpp | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 06813bac7c781f..65c1669f92b4d3 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -3840,11 +3840,11 @@ static const std::optional<BitPart> &
collectBitParts(Value *V, bool MatchBSwaps, bool MatchBitReversals,
std::map<Value *, std::optional<BitPart>> &BPS, int Depth,
bool &FoundRoot) {
- auto I = BPS.find(V);
- if (I != BPS.end())
+ auto [I, Inserted] = BPS.try_emplace(V);
+ if (!Inserted)
return I->second;
- auto &Result = BPS[V] = std::nullopt;
+ auto &Result = I->second;
auto BitWidth = V->getType()->getScalarSizeInBits();
// Can't do integer/elements > 128 bits.
More information about the llvm-commits
mailing list