-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[SLPVectorizer] Use DenseMap::{find,try_emplace} (NFC) #107123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm planning to deprecate and eventually remove DenseMap::FindAndConstruct in favor of operator[].
@llvm/pr-subscribers-llvm-transforms Author: Kazu Hirata (kazutakahirata) ChangesI'm planning to deprecate and eventually remove Full diff: https://github.com/llvm/llvm-project/pull/107123.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index 5c37c2fdd2de3e..8a239c163a84cb 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11841,9 +11841,9 @@ void BoUpSLP::reorderInputsAccordingToOpcode(ArrayRef<Value *> VL,
}
Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
- auto &Res = EntryToLastInstruction.FindAndConstruct(E);
- if (Res.second)
- return *Res.second;
+ auto &Res = EntryToLastInstruction[E];
+ if (Res)
+ return *Res;
// 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).
@@ -11947,10 +11947,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
@@ -11964,7 +11964,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
@@ -11985,10 +11985,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) {
|
The latest iteration uses |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LG
I'm planning to deprecate and eventually remove
DenseMap::FindAndConstruct in favor of operator[].