[llvm] [RISCV] Initial codegen support for the XRivosVizip extension (PR #131933)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 28 01:42:49 PDT 2025
================
@@ -4611,6 +4613,43 @@ static bool isElementRotate(std::array<std::pair<int, int>, 2> &SrcInfo,
SrcInfo[1].second - SrcInfo[0].second == (int)NumElts;
}
+static bool isAlternating(std::array<std::pair<int, int>, 2> &SrcInfo,
+ ArrayRef<int> Mask, bool &Polarity) {
+ int NumElts = Mask.size();
+ bool NonUndefFound = false;
+ for (unsigned i = 0; i != Mask.size(); ++i) {
+ int M = Mask[i];
+ if (M < 0)
+ continue;
+ int Src = M >= (int)NumElts;
+ int Diff = (int)i - (M % NumElts);
+ bool C = Src == SrcInfo[1].first && Diff == SrcInfo[1].second;
+ if (!NonUndefFound) {
+ NonUndefFound = true;
+ Polarity = (C == i % 2);
+ continue;
+ }
+ if ((Polarity && C != i % 2) || (!Polarity && C == i % 2))
+ return false;
+ }
+ return true;
+}
+
+static bool isZipEven(std::array<std::pair<int, int>, 2> &SrcInfo,
----------------
lukel97 wrote:
Nit, it took me a little while to remember the fields of SrcInfo again, for this + isZipOdd do you think it would be useful to add a comment showing like:
```
Src0: a0 a1 a2 a3
Src1: b0 b1 b2 b3
-----------------
Res: a0 b0 a2 b2
```
https://github.com/llvm/llvm-project/pull/131933
More information about the llvm-commits
mailing list