[PATCH] D149966: [SLP]Include cost of the reshuffling for same nodes with resizing.
Alexey Bataev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 7 14:54:06 PDT 2023
ABataev updated this revision to Diff 538277.
ABataev added a comment.
Herald added a subscriber: wangpc.
Rebase, ping!
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149966/new/
https://reviews.llvm.org/D149966
Files:
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
llvm/test/Transforms/SLPVectorizer/X86/crash_clear_undefs.ll
Index: llvm/test/Transforms/SLPVectorizer/X86/crash_clear_undefs.ll
===================================================================
--- llvm/test/Transforms/SLPVectorizer/X86/crash_clear_undefs.ll
+++ llvm/test/Transforms/SLPVectorizer/X86/crash_clear_undefs.ll
@@ -9,7 +9,7 @@
; YAML-NEXT: Function: foo
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'SLP vectorized with cost '
-; YAML-NEXT: - Cost: '-6'
+; YAML-NEXT: - Cost: '-5'
; YAML-NEXT: - String: ' and with tree size '
; YAML-NEXT: - TreeSize: '10'
; YAML-NEXT: ...
Index: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
===================================================================
--- llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -7001,6 +7001,17 @@
const TreeEntry *E2 = P2.get<const TreeEntry *>();
if (E->Scalars.size() == E2->Scalars.size())
CommonVF = VF = E->Scalars.size();
+ } else {
+ // P2 is empty, check that we have same node + reshuffle (if any).
+ if (E->Scalars.size() == Mask.size() && VF != Mask.size()) {
+ VF = E->Scalars.size();
+ SmallVector<int> CommonMask(Mask.begin(), Mask.end());
+ ::addMask(CommonMask, E->ReuseShuffleIndices);
+ V1 = Constant::getNullValue(
+ FixedVectorType::get(E->Scalars.front()->getType(), VF));
+ return BaseShuffleAnalysis::createShuffle<InstructionCost>(
+ V1, nullptr, Mask, Builder);
+ }
}
V1 = Constant::getNullValue(
FixedVectorType::get(E->Scalars.front()->getType(), VF));
@@ -7281,7 +7292,17 @@
dbgs()
<< "SLP: perfect diamond match for gather bundle that starts with "
<< *VL.front() << ".\n");
- return 0;
+ // Restore the mask for previous partially matched values.
+ for (auto [I, V] : enumerate(E->Scalars)) {
+ if (isa<PoisonValue>(V)) {
+ Mask[I] = PoisonMaskElem;
+ continue;
+ }
+ if (Mask[I] == PoisonMaskElem)
+ Mask[I] = Entries.front()->findLaneForValue(V);
+ }
+ Estimator.add(Entries.front(), Mask);
+ return Estimator.finalize(E->ReuseShuffleIndices);
}
if (!Resized) {
unsigned VF1 = Entries.front()->getVectorFactor();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149966.538277.patch
Type: text/x-patch
Size: 2417 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230707/65ee1253/attachment.bin>
More information about the llvm-commits
mailing list