[llvm] 53d3d1a - [SLPVectorizer] Avoid two successive hash lookups on the same key (#107143)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 3 14:51:04 PDT 2024
Author: Kazu Hirata
Date: 2024-09-03T14:51:00-07:00
New Revision: 53d3d1ab9abf28e92a27fce0a99ae83720d27d75
URL: https://github.com/llvm/llvm-project/commit/53d3d1ab9abf28e92a27fce0a99ae83720d27d75
DIFF: https://github.com/llvm/llvm-project/commit/53d3d1ab9abf28e92a27fce0a99ae83720d27d75.diff
LOG: [SLPVectorizer] Avoid two successive hash lookups on the same key (#107143)
This patch replaces the find-try_emplace sequence with just one call
to try_emplace, thereby avoiding two successive hash lookups on the
same key. I am not using the "inserted" boolean from try_emplace to
preserve the original behavior (that is, before PR 107123) that checks
to see if the value is nullptr or not.
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 3b45ca11eb6f89..cf802034cd56a3 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -11804,10 +11804,9 @@ void BoUpSLP::reorderInputsAccordingToOpcode(ArrayRef<Value *> VL,
}
Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
- auto It = EntryToLastInstruction.find(E);
- if (It != EntryToLastInstruction.end())
- return *It->second;
auto &Res = EntryToLastInstruction.try_emplace(E).first->second;
+ 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).
More information about the llvm-commits
mailing list