[llvm] [AArch64] Use EXT for byte shuffles with leading zeros (PR #193466)

David Green via llvm-commits llvm-commits at lists.llvm.org
Fri May 1 11:40:10 PDT 2026


================
@@ -14404,6 +14352,65 @@ static bool isEXTMask(ArrayRef<int> M, EVT VT, bool &ReverseEXT,
   return true;
 }
 
+// check if an EXT instruction can handle the shuffle mask when one source is a
+// splat. This matches shuffles where the splat occupies either a prefix or a
+// suffix and the remaining lanes are a contiguous slice from the non-splat
+// source.
+static bool isEXTMaskWithSplat(ArrayRef<int> M, EVT VT, unsigned SplatOperand,
+                               bool &ReverseEXT, unsigned &Imm) {
+  unsigned NumElts = VT.getVectorNumElements();
+  unsigned OtherBase = SplatOperand == 0 ? NumElts : 0;
+  auto IsSplatElt = [=](int Elt) {
+    return Elt < 0 ||
+           (SplatOperand == 0 ? Elt < (int)NumElts : Elt >= (int)NumElts);
+  };
+
+  unsigned PrefixSplatElts = 0;
+  while (PrefixSplatElts != NumElts && IsSplatElt(M[PrefixSplatElts]))
+    ++PrefixSplatElts;
+
+  if (0 < PrefixSplatElts && PrefixSplatElts < NumElts) {
----------------
davemgreen wrote:

PrefixSplatElts > 0 && ...

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


More information about the llvm-commits mailing list