[llvm] [RISCV][IA] Support masked.load for deinterleaveN matching (PR #149556)
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 21 10:56:01 PDT 2025
================
@@ -131,24 +131,40 @@ static bool getMemOperands(unsigned Factor, VectorType *VTy, Type *XLenTy,
: Constant::getAllOnesValue(XLenTy);
return true;
}
- auto *VPLdSt = cast<VPIntrinsic>(I);
- assert((VPLdSt->getIntrinsicID() == Intrinsic::vp_load ||
- VPLdSt->getIntrinsicID() == Intrinsic::vp_store) &&
- "Unexpected intrinsic");
- Ptr = VPLdSt->getMemoryPointerParam();
- Alignment = VPLdSt->getPointerAlignment().value_or(
- DL.getABITypeAlign(VTy->getElementType()));
+ if (auto *VPLdSt = dyn_cast<VPIntrinsic>(I)) {
+ assert((VPLdSt->getIntrinsicID() == Intrinsic::vp_load ||
+ VPLdSt->getIntrinsicID() == Intrinsic::vp_store) &&
+ "Unexpected intrinsic");
+ Ptr = VPLdSt->getMemoryPointerParam();
+ Alignment = VPLdSt->getPointerAlignment().value_or(
+ DL.getABITypeAlign(VTy->getElementType()));
+
+ assert(Mask && "vp.load and vp.store needs a mask!");
+
+ Value *WideEVL = VPLdSt->getVectorLengthParam();
+ // Conservatively check if EVL is a multiple of factor, otherwise some
+ // (trailing) elements might be lost after the transformation.
+ if (!isMultipleOfN(WideEVL, I->getDataLayout(), Factor))
+ return false;
- assert(Mask && "vp.load and vp.store needs a mask!");
+ auto *FactorC = ConstantInt::get(WideEVL->getType(), Factor);
+ VL = Builder.CreateZExt(Builder.CreateExactUDiv(WideEVL, FactorC), XLenTy);
+ return true;
+ }
+ auto *II = cast<IntrinsicInst>(I);
+ assert(II->getIntrinsicID() == Intrinsic::masked_load &&
+ "Unexpected intrinsic");
+ Ptr = II->getOperand(0);
+ Alignment = cast<ConstantInt>(II->getArgOperand(1))->getAlignValue();
- Value *WideEVL = VPLdSt->getVectorLengthParam();
- // Conservatively check if EVL is a multiple of factor, otherwise some
- // (trailing) elements might be lost after the transformation.
- if (!isMultipleOfN(WideEVL, I->getDataLayout(), Factor))
+ if (!isa<UndefValue>(II->getOperand(3)))
----------------
preames wrote:
I'd thought so to, but on reflection, I don't think we can. The problem is that the segment load only deinterleaves the loaded elements, we'd need to somehow deinterleave the pass thru elements separately, and then stick them in the right positions.
https://github.com/llvm/llvm-project/pull/149556
More information about the llvm-commits
mailing list