Skip to content

Commit 53d3d1a

Browse files
[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.
1 parent 98bde7f commit 53d3d1a

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11804,10 +11804,9 @@ void BoUpSLP::reorderInputsAccordingToOpcode(ArrayRef<Value *> VL,
1180411804
}
1180511805

1180611806
Instruction &BoUpSLP::getLastInstructionInBundle(const TreeEntry *E) {
11807-
auto It = EntryToLastInstruction.find(E);
11808-
if (It != EntryToLastInstruction.end())
11809-
return *It->second;
1181011807
auto &Res = EntryToLastInstruction.try_emplace(E).first->second;
11808+
if (Res)
11809+
return *Res;
1181111810
// Get the basic block this bundle is in. All instructions in the bundle
1181211811
// should be in this block (except for extractelement-like instructions with
1181311812
// constant indeces).

0 commit comments

Comments
 (0)