[llvm] r258995 - [TTI] Add getPrefetchDistance from PPCLoopDataPrefetch, NFC
Adam Nemet via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 27 14:21:26 PST 2016
Author: anemet
Date: Wed Jan 27 16:21:25 2016
New Revision: 258995
URL: http://llvm.org/viewvc/llvm-project?rev=258995&view=rev
Log:
[TTI] Add getPrefetchDistance from PPCLoopDataPrefetch, NFC
This patch is part of the work to make PPCLoopDataPrefetch
target-independent
(http://thread.gmane.org/gmane.comp.compilers.llvm.devel/92758).
As it was discussed in the above thread, getPrefetchDistance is
currently using instruction count which may change in the future.
Modified:
llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h
llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/trunk/lib/Analysis/TargetTransformInfo.cpp
llvm/trunk/lib/Target/PowerPC/PPCLoopDataPrefetch.cpp
llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.h
Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h?rev=258995&r1=258994&r2=258995&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/TargetTransformInfo.h Wed Jan 27 16:21:25 2016
@@ -419,6 +419,10 @@ public:
/// \return The size of a cache line in bytes.
unsigned getCacheLineSize() const;
+ /// \return How much before a load we should place the prefetch instruction.
+ /// This is currently measured in number of instructions.
+ unsigned getPrefetchDistance() const;
+
/// \return The maximum interleave factor that any transform should try to
/// perform for this target. This number depends on the level of parallelism
/// and the number of execution units in the CPU.
@@ -613,6 +617,7 @@ public:
virtual unsigned getNumberOfRegisters(bool Vector) = 0;
virtual unsigned getRegisterBitWidth(bool Vector) = 0;
virtual unsigned getCacheLineSize() = 0;
+ virtual unsigned getPrefetchDistance() = 0;
virtual unsigned getMaxInterleaveFactor(unsigned VF) = 0;
virtual unsigned
getArithmeticInstrCost(unsigned Opcode, Type *Ty, OperandValueKind Opd1Info,
@@ -782,6 +787,7 @@ public:
unsigned getCacheLineSize() override {
return Impl.getCacheLineSize();
}
+ unsigned getPrefetchDistance() override { return Impl.getPrefetchDistance(); }
unsigned getMaxInterleaveFactor(unsigned VF) override {
return Impl.getMaxInterleaveFactor(VF);
}
Modified: llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h?rev=258995&r1=258994&r2=258995&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/TargetTransformInfoImpl.h Wed Jan 27 16:21:25 2016
@@ -266,6 +266,8 @@ public:
unsigned getCacheLineSize() { return 0; }
+ unsigned getPrefetchDistance() { return 0; }
+
unsigned getMaxInterleaveFactor(unsigned VF) { return 1; }
unsigned getArithmeticInstrCost(unsigned Opcode, Type *Ty,
Modified: llvm/trunk/lib/Analysis/TargetTransformInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetTransformInfo.cpp?rev=258995&r1=258994&r2=258995&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/TargetTransformInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/TargetTransformInfo.cpp Wed Jan 27 16:21:25 2016
@@ -219,6 +219,10 @@ unsigned TargetTransformInfo::getCacheLi
return TTIImpl->getCacheLineSize();
}
+unsigned TargetTransformInfo::getPrefetchDistance() const {
+ return TTIImpl->getPrefetchDistance();
+}
+
unsigned TargetTransformInfo::getMaxInterleaveFactor(unsigned VF) const {
return TTIImpl->getMaxInterleaveFactor(VF);
}
Modified: llvm/trunk/lib/Target/PowerPC/PPCLoopDataPrefetch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCLoopDataPrefetch.cpp?rev=258995&r1=258994&r2=258995&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCLoopDataPrefetch.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCLoopDataPrefetch.cpp Wed Jan 27 16:21:25 2016
@@ -44,12 +44,6 @@ static cl::opt<bool>
PrefetchWrites("ppc-loop-prefetch-writes", cl::Hidden, cl::init(false),
cl::desc("Prefetch write addresses"));
-// This seems like a reasonable default for the BG/Q (this pass is enabled, by
-// default, only on the BG/Q).
-static cl::opt<unsigned>
-PrefDist("ppc-loop-prefetch-distance", cl::Hidden, cl::init(300),
- cl::desc("The loop prefetch distance"));
-
namespace llvm {
void initializePPCLoopDataPrefetchPass(PassRegistry&);
}
@@ -107,6 +101,8 @@ bool PPCLoopDataPrefetch::runOnFunction(
TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
assert(TTI->getCacheLineSize() && "Cache line size is not set for target");
+ assert(TTI->getPrefetchDistance() &&
+ "Prefetch distance is not set for target");
bool MadeChange = false;
@@ -147,7 +143,7 @@ bool PPCLoopDataPrefetch::runOnLoop(Loop
if (!LoopSize)
LoopSize = 1;
- unsigned ItersAhead = PrefDist/LoopSize;
+ unsigned ItersAhead = TTI->getPrefetchDistance() / LoopSize;
if (!ItersAhead)
ItersAhead = 1;
Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp?rev=258995&r1=258994&r2=258995&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.cpp Wed Jan 27 16:21:25 2016
@@ -27,6 +27,12 @@ static cl::opt<unsigned>
CacheLineSize("ppc-loop-prefetch-cache-line", cl::Hidden, cl::init(64),
cl::desc("The loop prefetch cache line size"));
+// This seems like a reasonable default for the BG/Q (this pass is enabled, by
+// default, only on the BG/Q).
+static cl::opt<unsigned>
+PrefDist("ppc-loop-prefetch-distance", cl::Hidden, cl::init(300),
+ cl::desc("The loop prefetch distance"));
+
//===----------------------------------------------------------------------===//
//
// PPC cost model.
@@ -242,6 +248,8 @@ unsigned PPCTTIImpl::getCacheLineSize()
return CacheLineSize;
}
+unsigned PPCTTIImpl::getPrefetchDistance() { return PrefDist; }
+
unsigned PPCTTIImpl::getMaxInterleaveFactor(unsigned VF) {
unsigned Directive = ST->getDarwinDirective();
// The 440 has no SIMD support, but floating-point instructions
Modified: llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.h?rev=258995&r1=258994&r2=258995&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.h (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCTargetTransformInfo.h Wed Jan 27 16:21:25 2016
@@ -71,6 +71,7 @@ public:
unsigned getNumberOfRegisters(bool Vector);
unsigned getRegisterBitWidth(bool Vector);
unsigned getCacheLineSize();
+ unsigned getPrefetchDistance();
unsigned getMaxInterleaveFactor(unsigned VF);
int getArithmeticInstrCost(
unsigned Opcode, Type *Ty,
More information about the llvm-commits
mailing list