Skip to content

Commit

Permalink
Revert "[RISCV][TTI] Recognize CONCAT_VECTORS if a shufflevector mask…
Browse files Browse the repository at this point in the history
… is multiple insert subvector. (llvm#110457)"

This reverts commit 554eaec.  Change was not approved when landed.
  • Loading branch information
preames committed Oct 7, 2024
1 parent 32e90bb commit f11568b
Show file tree
Hide file tree
Showing 5 changed files with 3 additions and 74 deletions.
47 changes: 0 additions & 47 deletions llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,49 +343,6 @@ RISCVTTIImpl::getConstantPoolLoadCost(Type *Ty, TTI::TargetCostKind CostKind) {
/*AddressSpace=*/0, CostKind);
}

InstructionCost
RISCVTTIImpl::isMultipleInsertSubvector(VectorType *Tp, ArrayRef<int> Mask,
TTI::TargetCostKind CostKind) {
if (!isa<FixedVectorType>(Tp))
return InstructionCost::getInvalid();
std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(Tp);
if (LT.second.getScalarSizeInBits() == 1)
return InstructionCost::getInvalid();
// Try to guess SubTp.
for (unsigned SubVecSize = 1, E = Mask.size(); SubVecSize < E;
SubVecSize <<= 1) {
if (E % SubVecSize != 0)
continue;
SmallVector<int> RepeatedPattern(createSequentialMask(0, SubVecSize, 0));
bool Skip = false;
for (unsigned I = 0; I != E; I += SubVecSize)
if (!Mask.slice(I, SubVecSize).equals(RepeatedPattern)) {
Skip = true;
break;
}
if (Skip)
continue;
InstructionCost Cost = 0;
unsigned NumSlides = Log2_32(E / SubVecSize);
// The cost of extraction from a subvector is 0 if the index is 0.
for (unsigned I = 0; I != NumSlides; ++I) {
unsigned InsertIndex = SubVecSize * (1 << I);
FixedVectorType *SubTp = FixedVectorType::get(
cast<FixedVectorType>(Tp)->getElementType(), InsertIndex);
FixedVectorType *DesTp =
FixedVectorType::getDoubleElementsVectorType(SubTp);
std::pair<InstructionCost, MVT> DesLT = getTypeLegalizationCost(DesTp);
// Add the cost of whole vector register move because the destination
// vector register group for vslideup cannot overlap the source.
Cost += DesLT.first * TLI->getLMULCost(DesLT.second);
Cost += getShuffleCost(TTI::SK_InsertSubvector, DesTp, {}, CostKind,
InsertIndex, SubTp);
}
return Cost;
}
return InstructionCost::getInvalid();
}

static VectorType *getVRGatherIndexType(MVT DataVT, const RISCVSubtarget &ST,
LLVMContext &C) {
assert((DataVT.getScalarSizeInBits() != 8 ||
Expand Down Expand Up @@ -437,10 +394,6 @@ InstructionCost RISCVTTIImpl::getShuffleCost(TTI::ShuffleKind Kind,
LT.second, CostKind);
}
}
if (InstructionCost Cost =
isMultipleInsertSubvector(Tp, Mask, CostKind);
Cost.isValid())
return Cost;
}
// vrgather + cost of generating the mask constant.
// We model this for an unknown mask with a single vrgather.
Expand Down
6 changes: 0 additions & 6 deletions llvm/lib/Target/RISCV/RISCVTargetTransformInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,6 @@ class RISCVTTIImpl : public BasicTTIImplBase<RISCVTTIImpl> {
/// type.
InstructionCost getConstantPoolLoadCost(Type *Ty,
TTI::TargetCostKind CostKind);

/// Return the cost if a shufflevector can be consist of multiple vslideup.
/// Otherwise, return InstructionCost::getInvalid().
InstructionCost isMultipleInsertSubvector(VectorType *Tp, ArrayRef<int> Mask,
TTI::TargetCostKind CostKind);

public:
explicit RISCVTTIImpl(const RISCVTargetMachine *TM, const Function &F)
: BaseT(TM, F.getDataLayout()), ST(TM->getSubtargetImpl(F)),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
; YAML-NEXT: Function: test
; YAML-NEXT: Args:
; YAML-NEXT: - String: 'Stores SLP vectorized with cost '
; YAML-NEXT: - Cost: '0'
; YAML-NEXT: - Cost: '2'
; YAML-NEXT: - String: ' and with tree size '
; YAML-NEXT: - TreeSize: '7'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
; YAML: Function: test1
; YAML: Args:
; YAML: - String: 'Stores SLP vectorized with cost '
; YAML: - Cost: '4'
; YAML: - Cost: '6'
; YAML: - String: ' and with tree size '
; YAML: - TreeSize: '5'

Expand Down Expand Up @@ -47,7 +47,7 @@ declare <4 x float> @llvm.fmuladd.v4f32(<4 x float>, <4 x float>, <4 x float>)
; YAML: Function: test2
; YAML: Args:
; YAML: - String: 'Stores SLP vectorized with cost '
; YAML: - Cost: '12'
; YAML: - Cost: '16'
; YAML: - String: ' and with tree size '
; YAML: - TreeSize: '5'

Expand Down

0 comments on commit f11568b

Please sign in to comment.