[llvm] [AArch64][CostModel] Lower cost of dupq (SVE2.1) (PR #144918)
David Green via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 23 08:42:41 PDT 2025
================
@@ -6723,6 +6724,29 @@ inline bool isREVMask(ArrayRef<int> M, unsigned EltSize, unsigned NumElts,
return true;
}
+/// isDUPQMask - matches a splat of equivalent lanes within segments of a given
+/// number of elements.
+inline std::optional<unsigned> isDUPQMask(ArrayRef<int> M, unsigned Segments,
+ unsigned NumElts) {
+ unsigned Lane = (unsigned)M[0];
+
+ // Make sure there's no size changes.
+ if (NumElts * Segments != M.size())
+ return std::nullopt;
+
+ // Check the first index corresponds to one of the lanes in the first segment.
+ if (Lane >= NumElts)
+ return std::nullopt;
+
+ // Check that all lanes match the first, adjusted for segment.
+ if (all_of(enumerate(M), [&](auto P) {
+ return (unsigned)P.value() == Lane + (P.index() / NumElts) * NumElts;
----------------
davemgreen wrote:
Add `P.value() == PoisonMaskElem ||` if undef elements are OK to ignore
https://github.com/llvm/llvm-project/pull/144918
More information about the llvm-commits
mailing list