[llvm] [RISCV] Expand vp.stride.load to splat of a scalar load. (PR #98140)

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 9 20:42:01 PDT 2024


================
@@ -155,6 +163,45 @@ bool RISCVCodeGenPrepare::visitIntrinsicInst(IntrinsicInst &I) {
   return true;
 }
 
+bool RISCVCodeGenPrepare::expandVPStrideLoad(IntrinsicInst &II) {
+  if (ST->hasOptimizedZeroStrideLoad())
+    return false;
+
+  Value *BasePtr, *VL;
+  using namespace PatternMatch;
+  if (!match(&II, m_Intrinsic<Intrinsic::experimental_vp_strided_load>(
+                      m_Value(BasePtr), m_Zero(), m_AllOnes(), m_Value(VL))))
+    return false;
+
+  if (!isKnownNonZero(VL, {*DL, DT, nullptr, &II}))
+    return false;
+
+  auto *VTy = cast<VectorType>(II.getType());
+
+  IRBuilder<> Builder(&II);
+
+  // Extend VL from i32 to XLen if needed.
+  if (ST->is64Bit())
+    VL = Builder.CreateZExt(VL, Builder.getInt64Ty());
+
+  Type *STy = VTy->getElementType();
+  Value *Val = Builder.CreateLoad(STy, BasePtr);
+  const auto &TLI = *ST->getTargetLowering();
+  Value *Res = Builder.CreateVectorSplat(VTy->getElementCount(), Val);
----------------
lukel97 wrote:

Should we move the Res into an else after the if below so we don't leave behind a dead splat in the scalable case

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


More information about the llvm-commits mailing list