[llvm] [SLPVectorizer] Use DenseMap::{find, try_emplace} (NFC) (PR #107123)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 3 11:31:21 PDT 2024
================
@@ -11841,9 +11841,10 @@ void BoUpSLP::reorderInputsAccordingToOpcode(ArrayRef<Value *> VL,
}
Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
- auto &Res = EntryToLastInstruction.FindAndConstruct(E);
- if (Res.second)
- return *Res.second;
+ auto It = EntryToLastInstruction.find(E);
+ if (It != EntryToLastInstruction.end())
+ return *It->second;
+ auto &Res = EntryToLastInstruction.try_emplace(E).first->second;
----------------
nikic wrote:
Why does this use find and then try_emplace? This will perform two hash lookups. It's enough to use only try_emplace and change behavior depending on the inserted boolean.
https://github.com/llvm/llvm-project/pull/107123
More information about the llvm-commits
mailing list