[llvm] [AArch64] Use dupq (SVE2.1) for segmented lane splats (PR #144482)

Graham Hunter via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 17 07:55:14 PDT 2025


================
@@ -13430,6 +13430,29 @@ static bool isUZP_v_undef_Mask(ArrayRef<int> M, EVT VT, unsigned &WhichResult) {
   return true;
 }
 
+/// isDUPQMask - matches a splat of equivalent lanes within 128b segments in
+/// the first vector operand.
+static std::optional<unsigned> isDUPQMask(ArrayRef<int> M, EVT VT) {
+  unsigned Lane = (unsigned)M[0];
+  unsigned Segments = VT.getFixedSizeInBits() / 128;
+  unsigned SegmentElts = VT.getVectorNumElements() / Segments;
+  if (SegmentElts * Segments != M.size())
+    return std::nullopt;
+
+  for (unsigned I = 0; I < Segments; ++I) {
+    unsigned Broadcast = (unsigned)M[I * SegmentElts];
+    if (Broadcast - (I * SegmentElts) > SegmentElts)
+      return std::nullopt;
+    for (unsigned J = 0; J < SegmentElts; ++J) {
+      int Idx = M[(I * SegmentElts) + J];
+      if ((unsigned)Idx != Broadcast)
+        return std::nullopt;
+    }
+  }
----------------
huntergr-arm wrote:

done

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


More information about the llvm-commits mailing list