mirror of
https://github.com/RPCSX/llvm.git
synced 2025-05-13 19:06:05 +00:00
[TTI] Add getCacheLineSize
Summary: And use it in PPCLoopDataPrefetch.cpp. @hfinkel, please let me know if your preference would be to preserve the ppc-loop-prefetch-cache-line option in order to be able to override the value of TTI::getCacheLineSize for PPC. Reviewers: hfinkel Subscribers: hulx2000, mcrosier, mssimpso, hfinkel, llvm-commits Differential Revision: http://reviews.llvm.org/D16306 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@258419 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
435b8e89a2
commit
c0ed657c76
@ -416,6 +416,9 @@ public:
|
|||||||
/// \return The width of the largest scalar or vector register type.
|
/// \return The width of the largest scalar or vector register type.
|
||||||
unsigned getRegisterBitWidth(bool Vector) const;
|
unsigned getRegisterBitWidth(bool Vector) const;
|
||||||
|
|
||||||
|
/// \return The size of a cache line in bytes.
|
||||||
|
unsigned getCacheLineSize() const;
|
||||||
|
|
||||||
/// \return The maximum interleave factor that any transform should try to
|
/// \return The maximum interleave factor that any transform should try to
|
||||||
/// perform for this target. This number depends on the level of parallelism
|
/// perform for this target. This number depends on the level of parallelism
|
||||||
/// and the number of execution units in the CPU.
|
/// and the number of execution units in the CPU.
|
||||||
@ -609,6 +612,7 @@ public:
|
|||||||
Type *Ty) = 0;
|
Type *Ty) = 0;
|
||||||
virtual unsigned getNumberOfRegisters(bool Vector) = 0;
|
virtual unsigned getNumberOfRegisters(bool Vector) = 0;
|
||||||
virtual unsigned getRegisterBitWidth(bool Vector) = 0;
|
virtual unsigned getRegisterBitWidth(bool Vector) = 0;
|
||||||
|
virtual unsigned getCacheLineSize() = 0;
|
||||||
virtual unsigned getMaxInterleaveFactor(unsigned VF) = 0;
|
virtual unsigned getMaxInterleaveFactor(unsigned VF) = 0;
|
||||||
virtual unsigned
|
virtual unsigned
|
||||||
getArithmeticInstrCost(unsigned Opcode, Type *Ty, OperandValueKind Opd1Info,
|
getArithmeticInstrCost(unsigned Opcode, Type *Ty, OperandValueKind Opd1Info,
|
||||||
@ -775,6 +779,9 @@ public:
|
|||||||
unsigned getRegisterBitWidth(bool Vector) override {
|
unsigned getRegisterBitWidth(bool Vector) override {
|
||||||
return Impl.getRegisterBitWidth(Vector);
|
return Impl.getRegisterBitWidth(Vector);
|
||||||
}
|
}
|
||||||
|
unsigned getCacheLineSize() override {
|
||||||
|
return Impl.getCacheLineSize();
|
||||||
|
}
|
||||||
unsigned getMaxInterleaveFactor(unsigned VF) override {
|
unsigned getMaxInterleaveFactor(unsigned VF) override {
|
||||||
return Impl.getMaxInterleaveFactor(VF);
|
return Impl.getMaxInterleaveFactor(VF);
|
||||||
}
|
}
|
||||||
|
@ -264,6 +264,8 @@ public:
|
|||||||
|
|
||||||
unsigned getRegisterBitWidth(bool Vector) { return 32; }
|
unsigned getRegisterBitWidth(bool Vector) { return 32; }
|
||||||
|
|
||||||
|
unsigned getCacheLineSize() { return 0; }
|
||||||
|
|
||||||
unsigned getMaxInterleaveFactor(unsigned VF) { return 1; }
|
unsigned getMaxInterleaveFactor(unsigned VF) { return 1; }
|
||||||
|
|
||||||
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty,
|
||||||
|
@ -215,6 +215,10 @@ unsigned TargetTransformInfo::getRegisterBitWidth(bool Vector) const {
|
|||||||
return TTIImpl->getRegisterBitWidth(Vector);
|
return TTIImpl->getRegisterBitWidth(Vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned TargetTransformInfo::getCacheLineSize() const {
|
||||||
|
return TTIImpl->getCacheLineSize();
|
||||||
|
}
|
||||||
|
|
||||||
unsigned TargetTransformInfo::getMaxInterleaveFactor(unsigned VF) const {
|
unsigned TargetTransformInfo::getMaxInterleaveFactor(unsigned VF) const {
|
||||||
return TTIImpl->getMaxInterleaveFactor(VF);
|
return TTIImpl->getMaxInterleaveFactor(VF);
|
||||||
}
|
}
|
||||||
|
@ -50,10 +50,6 @@ static cl::opt<unsigned>
|
|||||||
PrefDist("ppc-loop-prefetch-distance", cl::Hidden, cl::init(300),
|
PrefDist("ppc-loop-prefetch-distance", cl::Hidden, cl::init(300),
|
||||||
cl::desc("The loop prefetch distance"));
|
cl::desc("The loop prefetch distance"));
|
||||||
|
|
||||||
static cl::opt<unsigned>
|
|
||||||
CacheLineSize("ppc-loop-prefetch-cache-line", cl::Hidden, cl::init(64),
|
|
||||||
cl::desc("The loop prefetch cache line size"));
|
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
void initializePPCLoopDataPrefetchPass(PassRegistry&);
|
void initializePPCLoopDataPrefetchPass(PassRegistry&);
|
||||||
}
|
}
|
||||||
@ -110,6 +106,8 @@ bool PPCLoopDataPrefetch::runOnFunction(Function &F) {
|
|||||||
AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
|
AC = &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(F);
|
||||||
TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
|
TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
|
||||||
|
|
||||||
|
assert(TTI->getCacheLineSize() && "Cache line size is not set for target");
|
||||||
|
|
||||||
bool MadeChange = false;
|
bool MadeChange = false;
|
||||||
|
|
||||||
for (auto I = LI->begin(), IE = LI->end(); I != IE; ++I)
|
for (auto I = LI->begin(), IE = LI->end(); I != IE; ++I)
|
||||||
@ -193,7 +191,7 @@ bool PPCLoopDataPrefetch::runOnLoop(Loop *L) {
|
|||||||
if (const SCEVConstant *ConstPtrDiff =
|
if (const SCEVConstant *ConstPtrDiff =
|
||||||
dyn_cast<SCEVConstant>(PtrDiff)) {
|
dyn_cast<SCEVConstant>(PtrDiff)) {
|
||||||
int64_t PD = std::abs(ConstPtrDiff->getValue()->getSExtValue());
|
int64_t PD = std::abs(ConstPtrDiff->getValue()->getSExtValue());
|
||||||
if (PD < (int64_t) CacheLineSize) {
|
if (PD < (int64_t) TTI->getCacheLineSize()) {
|
||||||
DupPref = true;
|
DupPref = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,12 @@ using namespace llvm;
|
|||||||
static cl::opt<bool> DisablePPCConstHoist("disable-ppc-constant-hoisting",
|
static cl::opt<bool> DisablePPCConstHoist("disable-ppc-constant-hoisting",
|
||||||
cl::desc("disable constant hoisting on PPC"), cl::init(false), cl::Hidden);
|
cl::desc("disable constant hoisting on PPC"), cl::init(false), cl::Hidden);
|
||||||
|
|
||||||
|
// This is currently only used for the data prefetch pass which is only enabled
|
||||||
|
// for BG/Q by default.
|
||||||
|
static cl::opt<unsigned>
|
||||||
|
CacheLineSize("ppc-loop-prefetch-cache-line", cl::Hidden, cl::init(64),
|
||||||
|
cl::desc("The loop prefetch cache line size"));
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
//
|
//
|
||||||
// PPC cost model.
|
// PPC cost model.
|
||||||
@ -230,6 +236,12 @@ unsigned PPCTTIImpl::getRegisterBitWidth(bool Vector) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned PPCTTIImpl::getCacheLineSize() {
|
||||||
|
// This is currently only used for the data prefetch pass which is only
|
||||||
|
// enabled for BG/Q by default.
|
||||||
|
return CacheLineSize;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned PPCTTIImpl::getMaxInterleaveFactor(unsigned VF) {
|
unsigned PPCTTIImpl::getMaxInterleaveFactor(unsigned VF) {
|
||||||
unsigned Directive = ST->getDarwinDirective();
|
unsigned Directive = ST->getDarwinDirective();
|
||||||
// The 440 has no SIMD support, but floating-point instructions
|
// The 440 has no SIMD support, but floating-point instructions
|
||||||
|
@ -70,6 +70,7 @@ public:
|
|||||||
bool enableInterleavedAccessVectorization();
|
bool enableInterleavedAccessVectorization();
|
||||||
unsigned getNumberOfRegisters(bool Vector);
|
unsigned getNumberOfRegisters(bool Vector);
|
||||||
unsigned getRegisterBitWidth(bool Vector);
|
unsigned getRegisterBitWidth(bool Vector);
|
||||||
|
unsigned getCacheLineSize();
|
||||||
unsigned getMaxInterleaveFactor(unsigned VF);
|
unsigned getMaxInterleaveFactor(unsigned VF);
|
||||||
int getArithmeticInstrCost(
|
int getArithmeticInstrCost(
|
||||||
unsigned Opcode, Type *Ty,
|
unsigned Opcode, Type *Ty,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user