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

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 27 08:13:33 PST 2025


================
@@ -630,11 +630,34 @@ getVectorDeinterleaveFactor(IntrinsicInst *II,
   return true;
 }
 
+/// Check the interleaved mask
+///
+/// - if a value within the optional is non-nullptr, the value corresponds to
+///   deinterleaved mask
+/// - if a value within the option is nullptr, the value corresponds to all-true
+///   mask
+/// - return nullopt if mask cannot be deinterleaved
+static std::optional<Value *> getMask(Value *WideMask, unsigned Factor) {
+  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 &&
+          std::equal(Operands.begin(), Operands.end(), Operands.begin()))
+        return Operands.front();
+    }
+  }
+  if (match(WideMask, m_AllOnes()))
+    return nullptr;
----------------
lukel97 wrote:

If you return WideMask here then you can remove the optional and return nullptr on failure. Then you also don't need to handle the null Mask value in lowerInterleavedScalableLoad/Store

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


More information about the llvm-commits mailing list