Skip to content

Commit 2f17bfb

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.5
1 parent 5c181a9 commit 2f17bfb

File tree

5 files changed

+319
-32
lines changed

5 files changed

+319
-32
lines changed

llvm/include/llvm/Analysis/TargetTransformInfo.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,6 +1584,10 @@ class TargetTransformInfo {
15841584
/// split during legalization. Zero is returned when the answer is unknown.
15851585
unsigned getNumberOfParts(Type *Tp) const;
15861586

1587+
/// \return true if \p Tp represent a type, fully occupying whole register,
1588+
/// false otherwise.
1589+
bool isFullSingleRegisterType(Type *Tp) const;
1590+
15871591
/// \returns The cost of the address computation. For most targets this can be
15881592
/// merged into the instruction indexing mode. Some targets might want to
15891593
/// distinguish between address computation for memory operations on vector
@@ -2196,6 +2200,7 @@ class TargetTransformInfo::Concept {
21962200
ArrayRef<Type *> Tys,
21972201
TTI::TargetCostKind CostKind) = 0;
21982202
virtual unsigned getNumberOfParts(Type *Tp) = 0;
2203+
virtual bool isFullSingleRegisterType(Type *Tp) const = 0;
21992204
virtual InstructionCost
22002205
getAddressComputationCost(Type *Ty, ScalarEvolution *SE, const SCEV *Ptr) = 0;
22012206
virtual InstructionCost
@@ -2930,6 +2935,9 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
29302935
unsigned getNumberOfParts(Type *Tp) override {
29312936
return Impl.getNumberOfParts(Tp);
29322937
}
2938+
bool isFullSingleRegisterType(Type *Tp) const override {
2939+
return Impl.isFullSingleRegisterType(Tp);
2940+
}
29332941
InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *SE,
29342942
const SCEV *Ptr) override {
29352943
return Impl.getAddressComputationCost(Ty, SE, Ptr);

llvm/include/llvm/Analysis/TargetTransformInfoImpl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,6 +833,7 @@ class TargetTransformInfoImplBase {
833833

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

837838
InstructionCost getAddressComputationCost(Type *Tp, ScalarEvolution *,
838839
const SCEV *) const {

llvm/include/llvm/CodeGen/BasicTTIImpl.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2612,6 +2612,22 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
26122612
return *LT.first.getValue();
26132613
}
26142614

2615+
bool isFullSingleRegisterType(Type *Tp) const {
2616+
std::pair<InstructionCost, MVT> LT = getTypeLegalizationCost(Tp);
2617+
if (!LT.first.isValid() || LT.first > 1)
2618+
return false;
2619+
2620+
if (auto *FTp = dyn_cast<FixedVectorType>(Tp);
2621+
Tp && LT.second.isFixedLengthVector()) {
2622+
// Check if the n x i1 fits fully into largest integer.
2623+
if (unsigned VF = LT.second.getVectorNumElements();
2624+
LT.second.getVectorElementType() == MVT::i1)
2625+
return DL.isLegalInteger(VF) && !DL.isLegalInteger(VF * 2);
2626+
return FTp == EVT(LT.second).getTypeForEVT(Tp->getContext());
2627+
}
2628+
return false;
2629+
}
2630+
26152631
InstructionCost getAddressComputationCost(Type *Ty, ScalarEvolution *,
26162632
const SCEV *) {
26172633
return 0;

llvm/lib/Analysis/TargetTransformInfo.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1171,6 +1171,10 @@ unsigned TargetTransformInfo::getNumberOfParts(Type *Tp) const {
11711171
return TTIImpl->getNumberOfParts(Tp);
11721172
}
11731173

1174+
bool TargetTransformInfo::isFullSingleRegisterType(Type *Tp) const {
1175+
return TTIImpl->isFullSingleRegisterType(Tp);
1176+
}
1177+
11741178
InstructionCost
11751179
TargetTransformInfo::getAddressComputationCost(Type *Tp, ScalarEvolution *SE,
11761180
const SCEV *Ptr) const {

0 commit comments

Comments
 (0)