Skip to content

Commit 8207e95

Browse files
preamesMel-Chen
authored andcommitted
[LV] Check early for supported interleave factors with scalable types [nfc] (llvm#111592)
Previously, the cost model was returning an invalid cost. This simply moves the check from one place to another. This is mostly to make the cost modeling code a bit easier to follow. --------- Co-authored-by: Mel Chen <[email protected]>
1 parent 367a754 commit 8207e95

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3743,7 +3743,7 @@ InstructionCost AArch64TTIImpl::getInterleavedMemoryOpCost(
37433743
assert(Factor >= 2 && "Invalid interleave factor");
37443744
auto *VecVTy = cast<VectorType>(VecTy);
37453745

3746-
if (VecTy->isScalableTy() && (!ST->hasSVE() || Factor != 2))
3746+
if (VecTy->isScalableTy() && !ST->hasSVE())
37473747
return InstructionCost::getInvalid();
37483748

37493749
// Vectorization for masked interleaved accesses is only enabled for scalable

llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,6 @@ InstructionCost RISCVTTIImpl::getInterleavedMemoryOpCost(
675675
unsigned Opcode, Type *VecTy, unsigned Factor, ArrayRef<unsigned> Indices,
676676
Align Alignment, unsigned AddressSpace, TTI::TargetCostKind CostKind,
677677
bool UseMaskForCond, bool UseMaskForGaps) {
678-
if (isa<ScalableVectorType>(VecTy) && Factor != 2)
679-
return InstructionCost::getInvalid();
680678

681679
// The interleaved memory access pass will lower interleaved memory ops (i.e
682680
// a load and store followed by a specific shuffle) to vlseg/vsseg

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3413,6 +3413,7 @@ bool LoopVectorizationCostModel::interleavedAccessCanBeWidened(
34133413
"Decision should not be set yet.");
34143414
auto *Group = getInterleavedAccessGroup(I);
34153415
assert(Group && "Must have a group.");
3416+
unsigned InterleaveFactor = Group->getFactor();
34163417

34173418
// If the instruction's allocated size doesn't equal it's type size, it
34183419
// requires padding and will be scalarized.
@@ -3421,9 +3422,14 @@ bool LoopVectorizationCostModel::interleavedAccessCanBeWidened(
34213422
if (hasIrregularType(ScalarTy, DL))
34223423
return false;
34233424

3425+
// We currently only know how to emit interleave/deinterleave with
3426+
// Factor=2 for scalable vectors. This is purely an implementation
3427+
// limit.
3428+
if (VF.isScalable() && InterleaveFactor != 2)
3429+
return false;
3430+
34243431
// If the group involves a non-integral pointer, we may not be able to
34253432
// losslessly cast all values to a common type.
3426-
unsigned InterleaveFactor = Group->getFactor();
34273433
bool ScalarNI = DL.isNonIntegralPointerType(ScalarTy);
34283434
for (unsigned Idx = 0; Idx < InterleaveFactor; Idx++) {
34293435
Instruction *Member = Group->getMember(Idx);

0 commit comments

Comments
 (0)