Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions llvm/include/llvm/Analysis/TargetTransformInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1613,6 +1613,11 @@ class TargetTransformInfo {
/// split during legalization. Zero is returned when the answer is unknown.
unsigned getNumberOfParts(Type *Tp) const;

/// \return true if \p Tp represents a type, fully occupying whole register,
/// false otherwise. If \p Tp represents <n x i1>, it returns true if it fits
/// fully into largest integer.
bool isFullSingleRegisterType(Type *Tp) const;

/// \returns The cost of the address computation. For most targets this can be
/// merged into the instruction indexing mode. Some targets might want to
/// distinguish between address computation for memory operations on vector
Expand Down Expand Up @@ -2249,6 +2254,7 @@ class TargetTransformInfo::Concept {
ArrayRef<Type *> Tys,
TTI::TargetCostKind CostKind) = 0;
virtual unsigned getNumberOfParts(Type *Tp) = 0;
virtual bool isFullSingleRegisterType(Type *Tp) const = 0;
virtual InstructionCost
getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr) = 0;
virtual InstructionCost
Expand Down Expand Up @@ -3001,6 +3007,9 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
unsigned getNumberOfParts(Type *Tp) override {
return Impl.getNumberOfParts(Tp);
}
bool isFullSingleRegisterType(Type *Tp) const override {
return Impl.isFullSingleRegisterType(Tp);
}
InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *SE,
const SCEV *Ptr) override {
return Impl.getAddressComputationCost(Ty, SE, Ptr);
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ class TargetTransformInfoImplBase {

// Assume that we have a register of the right size for the type.
unsigned getNumberOfParts(Type *Tp) const { return 1; }
bool isFullSingleRegisterType(Type *Tp) const { return false; }

InstructionCost getAddressComputationCost(Type *Tp, ScalarEvolution *,
const SCEV *) const {
Expand Down
17 changes: 17 additions & 0 deletions llvm/include/llvm/CodeGen/BasicTTIImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -2710,6 +2710,23 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return *LT.first.getValue();
}

bool isFullSingleRegisterType(Type *Tp) const {
std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(Tp);
if (!LT.first.isValid() || LT.first > 1)
return false;

if (auto *FTp = dyn_cast<FixedVectorType>(Tp);
Tp && LT.second.isFixedLengthVector()) {
// Check if the n x i1 fits fully into largest integer.
if (LT.second.getVectorElementType() == MVT::i1) {
unsigned VF = LT.second.getVectorNumElements();
return DL.isLegalInteger(VF) && !DL.isLegalInteger(VF * 2);
}
return FTp == EVT(LT.second).getTypeForEVT(Tp->getContext());
}
return false;
}

InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *,
const SCEV *) {
return 0;
Expand Down
4 changes: 4 additions & 0 deletions llvm/lib/Analysis/TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1194,6 +1194,10 @@ unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
return TTIImpl->getNumberOfParts(Tp);
}

bool TargetTransformInfo::isFullSingleRegisterType(Type *Tp) const {
return TTIImpl->isFullSingleRegisterType(Tp);
}

InstructionCost
TargetTransformInfo::getAddressComputationCost(Type *Tp, ScalarEvolution *SE,
const SCEV *Ptr) const {
Expand Down
Loading
Loading