Skip to content

Commit

Permalink
Revert "[LoopVectorizer] NFCI: Calculate register usage based on TLI.…
Browse files Browse the repository at this point in the history
…getTypeLegalizationCost."

This reverts commits:
* [LoopVectorizer] NFCI: Calculate register usage based on TLI.getTypeLegalizationCost.
  b873aba.
* [LoopVectorizer] Silence warning in GetRegUsage.
  9ff7011.
  • Loading branch information
sdesmalen-arm committed Nov 11, 2020
1 parent 830ed64 commit 30fded7
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 19 deletions.
7 changes: 0 additions & 7 deletions llvm/include/llvm/Analysis/TargetTransformInfo.h
Expand Up @@ -708,9 +708,6 @@ class TargetTransformInfo {
/// Return true if this type is legal.
bool isTypeLegal(Type *Ty) const;

/// Returns the estimated number of registers required to represent \p Ty.
unsigned getRegUsageForType(Type *Ty) const;

/// Return true if switches should be turned into lookup tables for the
/// target.
bool shouldBuildLookupTables() const;
Expand Down Expand Up @@ -1450,7 +1447,6 @@ class TargetTransformInfo::Concept {
virtual bool isProfitableToHoist(Instruction *I) = 0;
virtual bool useAA() = 0;
virtual bool isTypeLegal(Type *Ty) = 0;
virtual unsigned getRegUsageForType(Type *Ty) = 0;
virtual bool shouldBuildLookupTables() = 0;
virtual bool shouldBuildLookupTablesForConstant(Constant *C) = 0;
virtual bool useColdCCForColdCall(Function &F) = 0;
Expand Down Expand Up @@ -1811,9 +1807,6 @@ class TargetTransformInfo::Model final : public TargetTransformInfo::Concept {
}
bool useAA() override { return Impl.useAA(); }
bool isTypeLegal(Type *Ty) override { return Impl.isTypeLegal(Ty); }
unsigned getRegUsageForType(Type *Ty) override {
return Impl.getRegUsageForType(Ty);
}
bool shouldBuildLookupTables() override {
return Impl.shouldBuildLookupTables();
}
Expand Down
2 changes: 0 additions & 2 deletions llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
Expand Up @@ -259,8 +259,6 @@ class TargetTransformInfoImplBase {

bool isTypeLegal(Type *Ty) { return false; }

unsigned getRegUsageForType(Type *Ty) { return 1; }

bool shouldBuildLookupTables() { return true; }
bool shouldBuildLookupTablesForConstant(Constant *C) { return true; }

Expand Down
4 changes: 0 additions & 4 deletions llvm/include/llvm/CodeGen/BasicTTIImpl.h
Expand Up @@ -297,10 +297,6 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
return getTLI()->isTypeLegal(VT);
}

unsigned getRegUsageForType(Type *Ty) {
return getTLI()->getTypeLegalizationCost(DL, Ty).first;
}

int getGEPCost(Type *PointeeType, const Value *Ptr,
ArrayRef<const Value *> Operands) {
return BaseT::getGEPCost(PointeeType, Ptr, Operands);
Expand Down
4 changes: 0 additions & 4 deletions llvm/lib/Analysis/TargetTransformInfo.cpp
Expand Up @@ -482,10 +482,6 @@ bool TargetTransformInfo::isTypeLegal(Type *Ty) const {
return TTIImpl->isTypeLegal(Ty);
}

unsigned TargetTransformInfo::getRegUsageForType(Type *Ty) const {
return TTIImpl->getRegUsageForType(Ty);
}

bool TargetTransformInfo::shouldBuildLookupTables() const {
return TTIImpl->shouldBuildLookupTables();
}
Expand Down
10 changes: 8 additions & 2 deletions llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
Expand Up @@ -5793,17 +5793,23 @@ LoopVectorizationCostModel::calculateRegisterUsage(ArrayRef<ElementCount> VFs) {
unsigned MaxSafeDepDist = -1U;
if (Legal->getMaxSafeDepDistBytes() != -1U)
MaxSafeDepDist = Legal->getMaxSafeDepDistBytes() * 8;
unsigned WidestRegister =
std::min(TTI.getRegisterBitWidth(true), MaxSafeDepDist);
const DataLayout &DL = TheFunction->getParent()->getDataLayout();

SmallVector<RegisterUsage, 8> RUs(VFs.size());
SmallVector<SmallMapVector<unsigned, unsigned, 4>, 8> MaxUsages(VFs.size());

LLVM_DEBUG(dbgs() << "LV(REG): Calculating max register usage:\n");

// A lambda that gets the register usage for the given type and VF.
auto GetRegUsage = [&TTI=TTI](Type *Ty, ElementCount VF) {
auto GetRegUsage = [&DL, WidestRegister](Type *Ty, ElementCount VF) {
if (Ty->isTokenTy())
return 0U;
return TTI.getRegUsageForType(VectorType::get(Ty, VF));
unsigned TypeSize = DL.getTypeSizeInBits(Ty->getScalarType());
assert(!VF.isScalable() && "scalable vectors not yet supported.");
return std::max<unsigned>(1, VF.getKnownMinValue() * TypeSize /
WidestRegister);
};

for (unsigned int i = 0, s = IdxToInstr.size(); i < s; ++i) {
Expand Down

0 comments on commit 30fded7

Please sign in to comment.