[llvm] [IA][RISCV] Support VP loads/stores in InterleavedAccessPass (PR #120490)

Min-Yih Hsu via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 30 12:08:35 PST 2025


================
@@ -630,11 +630,38 @@ getVectorDeinterleaveFactor(IntrinsicInst *II,
   return true;
 }
 
+// Return the corresponded deinterleaved mask, or nullptr if there is no valid
+// mask.
+static Value *getMask(Value *WideMask, unsigned Factor,
+                      VectorType *LeafValueTy) {
+  using namespace llvm::PatternMatch;
+  if (auto *IMI = dyn_cast<IntrinsicInst>(WideMask)) {
+    SmallVector<Value *, 8> Operands;
+    SmallVector<Instruction *, 8> DeadInsts;
+    if (getVectorInterleaveFactor(IMI, Operands, DeadInsts)) {
+      assert(!Operands.empty());
+      if (Operands.size() == Factor && llvm::all_equal(Operands))
+        return Operands[0];
+    }
+  }
+
+  if (match(WideMask, m_AllOnes())) {
+    // Scale the vector length of all-ones mask.
+    ElementCount OrigEC =
+        cast<VectorType>(WideMask->getType())->getElementCount();
+    if (OrigEC.getKnownMinValue() % Factor)
+      return nullptr;
----------------
mshockwave wrote:

Yes they're invariant because getVector(De)InterleaveFactor + vp.load/store signature have make sure it'll be a multiple of Factor. It's fixed now.

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


More information about the llvm-commits mailing list