[llvm] [LV] isScalarWithPredication to check for interleaved accesses (PR #194579)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 28 03:08:44 PDT 2026
================
@@ -2465,18 +2465,18 @@ bool LoopVectorizationCostModel::isScalarWithPredication(Instruction *I,
return getCallWideningDecision(cast<CallInst>(I), VF).Kind == CM_Scalarize;
case Instruction::Load:
case Instruction::Store: {
+ // We can use a masked ld/st for consecutive accesses or those that have
+ // been decided to use interleaving.
+ LoopVectorizationCostModel::InstWidening WidenKind =
+ getWideningDecision(I, VF);
auto *Ptr = getLoadStorePointerOperand(I);
auto *Ty = getLoadStoreType(I);
- unsigned AS = getLoadStoreAddressSpace(I);
- Type *VTy = Ty;
- if (VF.isVector())
- VTy = VectorType::get(Ty, VF);
- const Align Alignment = getLoadStoreAlignment(I);
- return isa<LoadInst>(I)
- ? !(Config.isLegalMaskedLoad(Ty, Ptr, Alignment, AS) ||
- TTI.isLegalMaskedGather(VTy, Alignment))
- : !(Config.isLegalMaskedStore(Ty, Ptr, Alignment, AS) ||
- TTI.isLegalMaskedScatter(VTy, Alignment));
+ bool CanUseLdSt =
+ Legal->isConsecutivePtr(Ty, Ptr) || WidenKind == CM_Interleave;
----------------
sdesmalen-arm wrote:
A similar, although not identical check is in `isLegalMaskedLoadOrStore`, where it checks if the pointer is consecutive or `IAI.isInterleaved()`. Is this different from checking `WidenKind == CM_Interleave`?
https://github.com/llvm/llvm-project/pull/194579
More information about the llvm-commits
mailing list