diff options
author | Adam Nemet <anemet@apple.com> | 2016-03-29 23:45:52 +0000 |
---|---|---|
committer | Adam Nemet <anemet@apple.com> | 2016-03-29 23:45:52 +0000 |
commit | 1428d41f9a8a9dfed10b12b756a8a78a9d38a572 (patch) | |
tree | b0a48e16e7aad6738ea0b4c3774e4356669d369d /llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp | |
parent | 1a470b6f7cc2530db8ef28222e5b094f7fdc8825 (diff) | |
download | llvm-1428d41f9a8a9dfed10b12b756a8a78a9d38a572.zip llvm-1428d41f9a8a9dfed10b12b756a8a78a9d38a572.tar.gz llvm-1428d41f9a8a9dfed10b12b756a8a78a9d38a572.tar.bz2 |
[LoopDataPrefetch] Centralize the tuning cl::opts under the pass
This is effectively NFC, minus the renaming of the options
(-cyclone-prefetch-distance -> -prefetch-distance).
The change was requested by Tim in D17943.
llvm-svn: 264806
Diffstat (limited to 'llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp')
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp b/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp index 82af46e..d6a8f48 100644 --- a/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp +++ b/llvm/lib/Transforms/Scalar/LoopDataPrefetch.cpp @@ -43,6 +43,19 @@ static cl::opt<bool> PrefetchWrites("loop-prefetch-writes", cl::Hidden, cl::init(false), cl::desc("Prefetch write addresses")); +static cl::opt<unsigned> + PrefetchDistance("prefetch-distance", + cl::desc("Number of instructions to prefetch ahead"), + cl::Hidden); + +static cl::opt<unsigned> + MinPrefetchStride("min-prefetch-stride", + cl::desc("Min stride to add prefetches"), cl::Hidden); + +static cl::opt<unsigned> MaxPrefetchIterationsAhead( + "max-prefetch-iters-ahead", + cl::desc("Max number of iterations to prefetch ahead"), cl::Hidden); + STATISTIC(NumPrefetches, "Number of prefetches inserted"); namespace llvm { @@ -79,6 +92,24 @@ namespace { /// warrant a prefetch. bool isStrideLargeEnough(const SCEVAddRecExpr *AR); + unsigned getMinPrefetchStride() { + if (MinPrefetchStride.getNumOccurrences() > 0) + return MinPrefetchStride; + return TTI->getMinPrefetchStride(); + } + + unsigned getPrefetchDistance() { + if (PrefetchDistance.getNumOccurrences() > 0) + return PrefetchDistance; + return TTI->getPrefetchDistance(); + } + + unsigned getMaxPrefetchIterationsAhead() { + if (MaxPrefetchIterationsAhead.getNumOccurrences() > 0) + return MaxPrefetchIterationsAhead; + return TTI->getMaxPrefetchIterationsAhead(); + } + AssumptionCache *AC; LoopInfo *LI; ScalarEvolution *SE; @@ -100,7 +131,7 @@ INITIALIZE_PASS_END(LoopDataPrefetch, "loop-data-prefetch", FunctionPass *llvm::createLoopDataPrefetchPass() { return new LoopDataPrefetch(); } bool LoopDataPrefetch::isStrideLargeEnough(const SCEVAddRecExpr *AR) { - unsigned TargetMinStride = TTI->getMinPrefetchStride(); + unsigned TargetMinStride = getMinPrefetchStride(); // No need to check if any stride goes. if (TargetMinStride <= 1) return true; @@ -125,7 +156,7 @@ bool LoopDataPrefetch::runOnFunction(Function &F) { // If PrefetchDistance is not set, don't run the pass. This gives an // opportunity for targets to run this pass for selected subtargets only // (whose TTI sets PrefetchDistance). - if (TTI->getPrefetchDistance() == 0) + if (getPrefetchDistance() == 0) return false; assert(TTI->getCacheLineSize() && "Cache line size is not set for target"); @@ -168,11 +199,11 @@ bool LoopDataPrefetch::runOnLoop(Loop *L) { if (!LoopSize) LoopSize = 1; - unsigned ItersAhead = TTI->getPrefetchDistance() / LoopSize; + unsigned ItersAhead = getPrefetchDistance() / LoopSize; if (!ItersAhead) ItersAhead = 1; - if (ItersAhead > TTI->getMaxPrefetchIterationsAhead()) + if (ItersAhead > getMaxPrefetchIterationsAhead()) return MadeChange; DEBUG(dbgs() << "Prefetching " << ItersAhead |