[llvm] [RISCV] Decompose locally repeating shuffles (without exact VLEN) (PR #125735)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 4 15:26:04 PST 2025


================
@@ -5324,6 +5324,21 @@ static SDValue lowerDisjointIndicesShuffle(ShuffleVectorSDNode *SVN,
   return DAG.getVectorShuffle(VT, DL, Select, DAG.getUNDEF(VT), NewMask);
 }
 
+/// Is this mask local (i.e. elements only move within their local span), and
+/// repeating (that is, the same rearrangement is being done within each span)?
+static bool isLocalRepeatingShuffle(ArrayRef<int> Mask, int Span) {
+  // TODO: Could improve the case where undef elements exist in the first span.
+  for (auto [I, M] : enumerate(Mask)) {
+    if (M == -1)
+      continue;
+    int ChunkLo = I - (I % Span);
+    int ChunkHi = ChunkLo + Span;
+    if (M < ChunkLo || M >= ChunkHi || M - ChunkLo != Mask[I % Span])
----------------
preames wrote:

That's the "TODO: Could improve the case where undef elements exist in the first span." just above. 

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


More information about the llvm-commits mailing list