[llvm] [AArch64] Add costs for LD3/LD4 shuffles. (PR #89268)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 18 10:51:14 PDT 2024
================
@@ -3815,6 +3815,27 @@ InstructionCost AArch64TTIImpl::getSpliceCost(VectorType *Tp, int Index) {
return LegalizationCost * LT.first;
}
+/// Check if the mask is a DE-interleave mask of the given factor
+/// \p Factor like:
+/// <Index, Index+Factor, ..., Index+(NumElts-1)*Factor>
+static bool isDeInterleaveMaskOfFactor(ArrayRef<int> Mask, unsigned Factor) {
+ // Check all potential start indices from 0 to (Factor - 1).
+ for (unsigned Index = 0; Index < Factor; Index++) {
+ unsigned i = 0;
+
+ // Check that elements are in ascending order by Factor. Ignore undef
+ // elements.
+ for (; i < Mask.size(); i++)
+ if (Mask[i] >= 0 && static_cast<unsigned>(Mask[i]) != Index + i * Factor)
+ break;
+
+ if (i == Mask.size())
+ return true;
+ }
+
+ return false;
+}
----------------
RKSimon wrote:
Move this to ShuffleVectorInst? Its likely we can use that in some general interleaved detection code.
https://github.com/llvm/llvm-project/pull/89268
More information about the llvm-commits
mailing list