[llvm] 126940b - [SLPVectorizer] Use DenseMap::{find,try_emplace} (NFC) (#107123)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 3 11:25:39 PDT 2024
Author: Kazu Hirata
Date: 2024-09-03T11:25:35-07:00
New Revision: 126940bde3e48ad9bf0a6966fc473e22d4dade7d
URL: https://github.com/llvm/llvm-project/commit/126940bde3e48ad9bf0a6966fc473e22d4dade7d
DIFF: https://github.com/llvm/llvm-project/commit/126940bde3e48ad9bf0a6966fc473e22d4dade7d.diff
LOG: [SLPVectorizer] Use DenseMap::{find,try_emplace} (NFC) (#107123)
I'm planning to deprecate and eventually remove
DenseMap::FindAndConstruct in favor of operator[].
Added:
Modified:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index afc2d28aa4c96d..3b45ca11eb6f89 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11804,9 +11804,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;
// Get the basic block this bundle is in. All instructions in the bundle
// should be in this block (except for extractelement-like instructions with
// constant indeces).
@@ -11910,10 +11911,10 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
return isa<ExtractElementInst, UndefValue>(V) ||
areAllOperandsNonInsts(V);
})))
- Res.second = FindLastInst();
+ Res = FindLastInst();
else
- Res.second = FindFirstInst();
- return *Res.second;
+ Res = FindFirstInst();
+ return *Res;
}
// Find the last instruction. The common case should be that BB has been
@@ -11927,7 +11928,7 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
auto *Bundle = BlocksSchedules[BB]->getScheduleData(V);
if (Bundle && Bundle->isPartOfBundle())
for (; Bundle; Bundle = Bundle->NextInBundle)
- Res.second = Bundle->Inst;
+ Res = Bundle->Inst;
}
// LastInst can still be null at this point if there's either not an entry
@@ -11948,10 +11949,10 @@ Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
// not ideal. However, this should be exceedingly rare since it requires that
// we both exit early from buildTree_rec and that the bundle be out-of-order
// (causing us to iterate all the way to the end of the block).
- if (!Res.second)
- Res.second = FindLastInst();
- assert(Res.second && "Failed to find last instruction in bundle");
- return *Res.second;
+ if (!Res)
+ Res = FindLastInst();
+ assert(Res && "Failed to find last instruction in bundle");
+ return *Res;
}
void BoUpSLP::setInsertPointAfterBundle(const TreeEntry *E) {
More information about the llvm-commits
mailing list