[llvm] [RISCV][TTI] Enable masked interleave vectorization (PR #150074)
Luke Lau via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 23 01:14:29 PDT 2025
================
@@ -979,12 +979,14 @@ InstructionCost RISCVTTIImpl::getInterleavedMemoryOpCost(
Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
bool UseMaskForCond, bool UseMaskForGaps) const {
- // The interleaved memory access pass will lower interleaved memory ops (i.e
- // a load and store followed by a specific shuffle) to vlseg/vsseg
- // intrinsics.
- if (!UseMaskForCond && !UseMaskForGaps &&
+ auto *VTy = cast<VectorType>(VecTy);
+
+ // The interleaved memory access pass will lower (de)interleave ops combined
+ // with an adjacent appropriate memory to vlseg/vsseg intrinsics. We
+ // currently only support masking for the scalable path. vlseg/vsseg only
+ // support masking per-iteration (i.e. condition), not per-segment (i.e. gap).
+ if ((VTy->isScalableTy() || !UseMaskForCond) && !UseMaskForGaps &&
----------------
lukel97 wrote:
I think it's because we don't handle llvm.masked.{load,store} with shufflevectors, only load and vp.load:
https://github.com/llvm/llvm-project/blob/b7889a65a8e54f2d9c7f578a515a7bf970044bfe/llvm/lib/CodeGen/InterleavedAccessPass.cpp#L689-L695
But yes, it seems a shame that we already have this fixed-length mask functionality in getMask. Hopefully it's not too difficult to extend InterleavedAccessPass to handle llvm.masked.{load,store} with shufflevectors. I think that would round out support for all the different ways of expressing interleaves.
Which as a side note, I think that would mean there's 12 possible different types of [de]interleaves: Either shufflevector or intrinsic based, for each of load, store, masked.load, masked.store, vp.load or vp.store. That's a lot!
https://github.com/llvm/llvm-project/pull/150074
More information about the llvm-commits
mailing list