[llvm] 6ec113d - [Local] Avoid repeated map lookups (NFC) (#113072)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 20 09:06:25 PDT 2024
Author: Kazu Hirata
Date: 2024-10-20T09:06:22-07:00
New Revision: 6ec113d4c35db934ec8fdb3d226d2d8e525a1f84
URL: https://github.com/llvm/llvm-project/commit/6ec113d4c35db934ec8fdb3d226d2d8e525a1f84
DIFF: https://github.com/llvm/llvm-project/commit/6ec113d4c35db934ec8fdb3d226d2d8e525a1f84.diff
LOG: [Local] Avoid repeated map lookups (NFC) (#113072)
Added:
Modified:
llvm/lib/Transforms/Utils/Local.cpp
Removed:
################################################################################
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