[llvm] [Local] Avoid repeated map lookups (NFC) (PR #113072)
via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 19 21:00:15 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-transforms
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/113072.diff
1 Files Affected:
- (modified) llvm/lib/Transforms/Utils/Local.cpp (+3-3)
``````````diff
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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/113072
More information about the llvm-commits
mailing list