Skip to content

Commit daf4a06

Browse files
[SLP]Try detect strided loads, if any pointer op require extraction.
If any pointer operand of the non-cosencutive loads is an instructions with the user, which is not part of the current graph, and, thus, requires emission of the extractelement instruction, better to try to detect if the load sequence can be repsented as strided load and extractelement instructions for pointers are not required. Reviewers: preames, RKSimon, topperc Reviewed By: RKSimon Pull Request: #101668
1 parent f9b69a3 commit daf4a06

File tree

3 files changed

+312
-352
lines changed

3 files changed

+312
-352
lines changed

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4617,7 +4617,17 @@ BoUpSLP::LoadsState BoUpSLP::canVectorizeLoads(
46174617
// 3. The loads are ordered, or number of unordered loads <=
46184618
// MaxProfitableUnorderedLoads, or loads are in reversed order.
46194619
// (this check is to avoid extra costs for very expensive shuffles).
4620-
if (IsPossibleStrided && (((Sz > MinProfitableStridedLoads ||
4620+
// 4. Any pointer operand is an instruction with the users outside of the
4621+
// current graph (for masked gathers extra extractelement instructions
4622+
// might be required).
4623+
auto IsAnyPointerUsedOutGraph =
4624+
IsPossibleStrided && any_of(PointerOps, [&](Value *V) {
4625+
return isa<Instruction>(V) && any_of(V->users(), [&](User *U) {
4626+
return !getTreeEntry(U) && !MustGather.contains(U);
4627+
});
4628+
});
4629+
if (IsPossibleStrided && (IsAnyPointerUsedOutGraph ||
4630+
((Sz > MinProfitableStridedLoads ||
46214631
(static_cast<unsigned>(std::abs(*Diff)) <=
46224632
MaxProfitableLoadStride * Sz &&
46234633
isPowerOf2_32(std::abs(*Diff)))) &&

0 commit comments

Comments
 (0)