[PATCH] D102023: [SLP]Do not count perfect diamond matches for gathers several times.
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu May 6 13:47:25 PDT 2021
ABataev created this revision.
ABataev added reviewers: spatel, RKSimon, dtemirbulatov, anton-afanasyev.
Herald added a subscriber: hiraditya.
ABataev requested review of this revision.
Herald added a project: LLVM.
Need to remove the old code for avoiding double counting of the gather
nodes with perfect diamond matches within the tree after we started
detecting perfect/shuffled matching in one of the previous patches. We
may skip the cost for such nodes completely.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D102023
Files:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/AArch64/gather-cost.ll
Index: llvm/test/Transforms/SLPVectorizer/AArch64/gather-cost.ll
===================================================================
--- llvm/test/Transforms/SLPVectorizer/AArch64/gather-cost.ll
+++ llvm/test/Transforms/SLPVectorizer/AArch64/gather-cost.ll
@@ -10,7 +10,7 @@
; REMARK-LABEL: Function: gather_multiple_use
; REMARK: Args:
; REMARK-NEXT: - String: 'Vectorized horizontal reduction with cost '
-; REMARK-NEXT: - Cost: '-16'
+; REMARK-NEXT: - Cost: '-7'
;
; REMARK-NOT: Function: gather_load
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -4233,27 +4233,6 @@
for (unsigned I = 0, E = VectorizableTree.size(); I < E; ++I) {
TreeEntry &TE = *VectorizableTree[I].get();
- // We create duplicate tree entries for gather sequences that have multiple
- // uses. However, we should not compute the cost of duplicate sequences.
- // For example, if we have a build vector (i.e., insertelement sequence)
- // that is used by more than one vector instruction, we only need to
- // compute the cost of the insertelement instructions once. The redundant
- // instructions will be eliminated by CSE.
- //
- // We should consider not creating duplicate tree entries for gather
- // sequences, and instead add additional edges to the tree representing
- // their uses. Since such an approach results in fewer total entries,
- // existing heuristics based on tree size may yield different results.
- //
- if (TE.State == TreeEntry::NeedToGather &&
- std::any_of(std::next(VectorizableTree.begin(), I + 1),
- VectorizableTree.end(),
- [TE](const std::unique_ptr<TreeEntry> &EntryPtr) {
- return EntryPtr->State == TreeEntry::NeedToGather &&
- EntryPtr->isSame(TE.Scalars);
- }))
- continue;
-
InstructionCost C = getEntryCost(&TE);
Cost += C;
LLVM_DEBUG(dbgs() << "SLP: Adding cost " << C
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102023.343494.patch
Type: text/x-patch
Size: 2171 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210506/66fb2fee/attachment.bin>
More information about the llvm-commits
mailing list