Skip to content

Commit 6514602

Browse files
committed
[LV] Check early for supported interleave factors with scalable types [nfc]
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.
1 parent f11568b commit 6514602

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

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
@@ -3406,6 +3406,7 @@ bool LoopVectorizationCostModel::interleavedAccessCanBeWidened(
34063406
"Decision should not be set yet.");
34073407
auto *Group = getInterleavedAccessGroup(I);
34083408
assert(Group && "Must have a group.");
3409+
unsigned InterleaveFactor = Group->getFactor();
34093410

34103411
// If the instruction's allocated size doesn't equal it's type size, it
34113412
// requires padding and will be scalarized.
@@ -3414,9 +3415,14 @@ bool LoopVectorizationCostModel::interleavedAccessCanBeWidened(
34143415
if (hasIrregularType(ScalarTy, DL))
34153416
return false;
34163417

3418+
// We currently only know how to emit interleave/deinterleave with
3419+
// Factor=2 for scalable vectors. This is purely an implementation
3420+
// limit.
3421+
if (VF.isScalable() && InterleaveFactor != 2)
3422+
return false;
3423+
34173424
// If the group involves a non-integral pointer, we may not be able to
34183425
// losslessly cast all values to a common type.
3419-
unsigned InterleaveFactor = Group->getFactor();
34203426
bool ScalarNI = DL.isNonIntegralPointerType(ScalarTy);
34213427
for (unsigned Idx = 0; Idx < InterleaveFactor; Idx++) {
34223428
Instruction *Member = Group->getMember(Idx);

0 commit comments

Comments
 (0)