Skip to content

Commit fb35bb4

Browse files
committed
[SLP][NFC]Build value-to-gather-nodes map during nodes building, NFC.
1 parent c79f94d commit fb35bb4

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2883,6 +2883,10 @@ class BoUpSLP {
28832883
assert(!BundleMember && "Bundle and VL out of sync");
28842884
} else {
28852885
MustGather.insert(VL.begin(), VL.end());
2886+
// Build a map for gathered scalars to the nodes where they are used.
2887+
for (Value *V : VL)
2888+
if (!isConstant(V))
2889+
ValueToGatherNodes.try_emplace(V).first->getSecond().insert(Last);
28862890
}
28872891

28882892
if (UserTreeIdx.UserTE)
@@ -8865,16 +8869,6 @@ static T *performExtractsShuffleAction(
88658869
}
88668870

88678871
InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
8868-
// Build a map for gathered scalars to the nodes where they are used.
8869-
ValueToGatherNodes.clear();
8870-
for (const std::unique_ptr<TreeEntry> &EntryPtr : VectorizableTree) {
8871-
if (EntryPtr->State != TreeEntry::NeedToGather)
8872-
continue;
8873-
for (Value *V : EntryPtr->Scalars)
8874-
if (!isConstant(V))
8875-
ValueToGatherNodes.try_emplace(V).first->getSecond().insert(
8876-
EntryPtr.get());
8877-
}
88788872
InstructionCost Cost = 0;
88798873
LLVM_DEBUG(dbgs() << "SLP: Calculating cost for tree of size "
88808874
<< VectorizableTree.size() << ".\n");

0 commit comments

Comments
 (0)