[llvm] [IA][RISCV] Support VP loads/stores in InterleavedAccessPass (PR #120490)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Thu Jan 30 18:57:18 PST 2025
================
@@ -22529,6 +22530,233 @@ bool RISCVTargetLowering::lowerInterleaveIntrinsicToStore(
return true;
}
+static bool isMultipleOfN(const Value *V, const DataLayout &DL, unsigned N) {
+ assert(N);
+ if (N == 1)
+ return true;
+
+ if (isPowerOf2_32(N)) {
+ KnownBits KB = llvm::computeKnownBits(V, DL);
+ return KB.countMinTrailingZeros() >= Log2_32(N);
+ }
+
+ using namespace PatternMatch;
+ // Right now we're only recognizing the simplest pattern.
+ uint64_t C;
+ return match(V, m_c_Mul(m_Value(), m_ConstantInt(C))) && C && C % N == 0;
+}
+
+/// Lower an interleaved vp.load into a vlsegN intrinsic.
+///
+/// E.g. Lower an interleaved vp.load (Factor = 2):
+/// %l = call <vscale x 64 x i8> @llvm.vp.load.nxv64i8.p0(ptr %ptr,
+/// %mask,
+/// i32 %wide.rvl)
+/// %dl = tail call { <vscale x 32 x i8>, <vscale x 32 x i8> }
+/// @llvm.vector.deinterleave2.nxv64i8(
+/// <vscale x 64 x i8> %l)
+/// %r0 = extractvalue { <vscale x 32 x i8>, <vscale x 32 x i8> } %dl, 0
+/// %r1 = extractvalue { <vscale x 32 x i8>, <vscale x 32 x i8> } %dl, 1
----------------
lukel97 wrote:
Nit, should we add the insertvalues into the example here? And maybe leave a TODO to match factor 2 deinterleaves without them?
https://github.com/llvm/llvm-project/pull/120490
More information about the llvm-commits
mailing list