[llvm] [AArch64][CostModel] Lower cost of dupq (SVE2.1) (PR #144918)

Gaƫtan Bossu via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 24 01:19:21 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) {
----------------
gbossu wrote:

Super-nit: Introduce `const unsigned IndexInSegment = P.index() / NumElts` to make the computation immediately obvious.

https://github.com/llvm/llvm-project/pull/144918


More information about the llvm-commits mailing list