diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 06813bac7c781..65c1669f92b4d 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -3840,11 +3840,11 @@ static const std::optional & collectBitParts(Value *V, bool MatchBSwaps, bool MatchBitReversals, std::map> &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.