[llvm] [RISCV] Recognize VLA shift pairs from shuffle masks (PR #127710)

Craig Topper via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 18 19:58:05 PST 2025


================
@@ -4563,6 +4563,49 @@ static bool isInterleaveShuffle(ArrayRef<int> Mask, MVT VT, int &EvenSrc,
   return ((EvenSrc % HalfNumElts) == 0) && ((OddSrc % HalfNumElts) == 0);
 }
 
+/// Is this mask representing a masked combination of two slides?
+static bool isMaskedSlidePair(ArrayRef<int> Mask,
+                              std::pair<int, int> SrcInfo[2]) {
+  int NumElts = Mask.size();
+  int SIGNAL_VAL = NumElts * 2;
+  SrcInfo[0] = {-1, SIGNAL_VAL};
+  SrcInfo[1] = {-1, SIGNAL_VAL};
+  for (unsigned i = 0; i != Mask.size(); ++i) {
+    int M = Mask[i];
+    if (M < 0)
+      continue;
+    int Src = M >= (int)NumElts;
+    int Diff = (M % NumElts) - (int)i;
+    bool Match = false;
+    for (int j = 0; j < 2; j++) {
+      if (SrcInfo[j].first == -1)
+        SrcInfo[j].first = Src;
+      if (SrcInfo[j].second == SIGNAL_VAL)
----------------
topperc wrote:

Do we need 2 ifs? Can we do

```
if (SrcInfo[j].first == -1) {
  SrcInfo[j].first = Src;
  SrcInfo[j].second = Diff;
}
```

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


More information about the llvm-commits mailing list