diff options
author | Adam Nemet <anemet@apple.com> | 2015-02-19 19:14:52 +0000 |
---|---|---|
committer | Adam Nemet <anemet@apple.com> | 2015-02-19 19:14:52 +0000 |
commit | f219c6472355e0b5d207281e1fb19031c90998d2 (patch) | |
tree | 1883e7e2960a768ed57287558d8bb2d60fb048e6 /llvm/lib/Analysis/LoopAccessAnalysis.cpp | |
parent | 04d4163e951bcb006c2aa7ea0271e1404fa92a32 (diff) | |
download | bcm5719-llvm-f219c6472355e0b5d207281e1fb19031c90998d2.tar.gz bcm5719-llvm-f219c6472355e0b5d207281e1fb19031c90998d2.zip |
[LoopAccesses] Make VectorizerParams global + fix for cyclic dep
As LAA is becoming a pass, we can no longer pass the params to its
constructor. This changes the command line flags to have external
storage. These can now be accessed both from LV and LAA.
VectorizerParams is moved out of LoopAccessInfo in order to shorten the
code to access it.
This commits also has the fix (D7731) to the break dependence cycle
between the analysis and vector libraries.
This is part of the patchset that converts LoopAccessAnalysis into an
actual analysis pass.
llvm-svn: 229890
Diffstat (limited to 'llvm/lib/Analysis/LoopAccessAnalysis.cpp')
-rw-r--r-- | llvm/lib/Analysis/LoopAccessAnalysis.cpp | 57 |
1 files changed, 41 insertions, 16 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 35c5807be08..c0cad5c0894 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -25,6 +25,31 @@ using namespace llvm; #define DEBUG_TYPE "loop-vectorize" +static cl::opt<unsigned, true> +VectorizationFactor("force-vector-width", cl::Hidden, + cl::desc("Sets the SIMD width. Zero is autoselect."), + cl::location(VectorizerParams::VectorizationFactor)); +unsigned VectorizerParams::VectorizationFactor = 0; + +static cl::opt<unsigned, true> +VectorizationInterleave("force-vector-interleave", cl::Hidden, + cl::desc("Sets the vectorization interleave count. " + "Zero is autoselect."), + cl::location( + VectorizerParams::VectorizationInterleave)); +unsigned VectorizerParams::VectorizationInterleave = 0; + +/// When performing memory disambiguation checks at runtime do not make more +/// than this number of comparisons. +const unsigned VectorizerParams::RuntimeMemoryCheckThreshold = 8; + +/// Maximum SIMD width. +const unsigned VectorizerParams::MaxVectorWidth = 64; + +bool VectorizerParams::isInterleaveForced() { + return ::VectorizationInterleave.getNumOccurrences() > 0; +} + void VectorizationReport::emitAnalysis(VectorizationReport &Message, const Function *TheFunction, const Loop *TheLoop) { @@ -454,10 +479,9 @@ public: typedef PointerIntPair<Value *, 1, bool> MemAccessInfo; typedef SmallPtrSet<MemAccessInfo, 8> MemAccessInfoSet; - MemoryDepChecker(ScalarEvolution *Se, const DataLayout *Dl, const Loop *L, - const LoopAccessInfo::VectorizerParams &VectParams) + MemoryDepChecker(ScalarEvolution *Se, const DataLayout *Dl, const Loop *L) : SE(Se), DL(Dl), InnermostLoop(L), AccessIdx(0), - ShouldRetryWithRuntimeCheck(false), VectParams(VectParams) {} + ShouldRetryWithRuntimeCheck(false) {} /// \brief Register the location (instructions are given increasing numbers) /// of a write access. @@ -512,9 +536,6 @@ private: /// vectorize this loop with runtime checks. bool ShouldRetryWithRuntimeCheck; - /// \brief Vectorizer parameters used by the analysis. - LoopAccessInfo::VectorizerParams VectParams; - /// \brief Check whether there is a plausible dependence between the two /// accesses. /// @@ -638,7 +659,8 @@ bool MemoryDepChecker::couldPreventStoreLoadForward(unsigned Distance, // Store-load forwarding distance. const unsigned NumCyclesForStoreLoadThroughMemory = 8*TypeByteSize; // Maximum vector factor. - unsigned MaxVFWithoutSLForwardIssues = VectParams.MaxVectorWidth*TypeByteSize; + unsigned MaxVFWithoutSLForwardIssues = + VectorizerParams::MaxVectorWidth * TypeByteSize; if(MaxSafeDepDistBytes < MaxVFWithoutSLForwardIssues) MaxVFWithoutSLForwardIssues = MaxSafeDepDistBytes; @@ -657,7 +679,8 @@ bool MemoryDepChecker::couldPreventStoreLoadForward(unsigned Distance, } if (MaxVFWithoutSLForwardIssues < MaxSafeDepDistBytes && - MaxVFWithoutSLForwardIssues != VectParams.MaxVectorWidth*TypeByteSize) + MaxVFWithoutSLForwardIssues != + VectorizerParams::MaxVectorWidth * TypeByteSize) MaxSafeDepDistBytes = MaxVFWithoutSLForwardIssues; return false; } @@ -762,10 +785,10 @@ bool MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx, unsigned Distance = (unsigned) Val.getZExtValue(); // Bail out early if passed-in parameters make vectorization not feasible. - unsigned ForcedFactor = (VectParams.VectorizationFactor ? - VectParams.VectorizationFactor : 1); - unsigned ForcedUnroll = (VectParams.VectorizationInterleave ? - VectParams.VectorizationInterleave : 1); + unsigned ForcedFactor = (VectorizerParams::VectorizationFactor ? + VectorizerParams::VectorizationFactor : 1); + unsigned ForcedUnroll = (VectorizerParams::VectorizationInterleave ? + VectorizerParams::VectorizationInterleave : 1); // The distance must be bigger than the size needed for a vectorized version // of the operation and the size of the vectorized operation must not be @@ -848,7 +871,7 @@ bool LoopAccessInfo::canVectorizeMemory(ValueToValueMap &Strides) { PtrRtCheck.Need = false; const bool IsAnnotatedParallel = TheLoop->isAnnotatedParallel(); - MemoryDepChecker DepChecker(SE, DL, TheLoop, VectParams); + MemoryDepChecker DepChecker(SE, DL, TheLoop); // For each block. for (Loop::block_iterator bb = TheLoop->block_begin(), @@ -1017,7 +1040,8 @@ bool LoopAccessInfo::canVectorizeMemory(ValueToValueMap &Strides) { // Check that we did not collect too many pointers or found an unsizeable // pointer. - if (!CanDoRT || NumComparisons > VectParams.RuntimeMemoryCheckThreshold) { + if (!CanDoRT || + NumComparisons > VectorizerParams::RuntimeMemoryCheckThreshold) { PtrRtCheck.reset(); CanDoRT = false; } @@ -1057,14 +1081,15 @@ bool LoopAccessInfo::canVectorizeMemory(ValueToValueMap &Strides) { TheLoop, Strides, true); // Check that we did not collect too many pointers or found an unsizeable // pointer. - if (!CanDoRT || NumComparisons > VectParams.RuntimeMemoryCheckThreshold) { + if (!CanDoRT || + NumComparisons > VectorizerParams::RuntimeMemoryCheckThreshold) { if (!CanDoRT && NumComparisons > 0) emitAnalysis(VectorizationReport() << "cannot check memory dependencies at runtime"); else emitAnalysis(VectorizationReport() << NumComparisons << " exceeds limit of " - << VectParams.RuntimeMemoryCheckThreshold + << VectorizerParams::RuntimeMemoryCheckThreshold << " dependent memory operations checked at runtime"); DEBUG(dbgs() << "LV: Can't vectorize with memory checks\n"); PtrRtCheck.reset(); |