summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Analysis/LoopAccessAnalysis.h3
-rw-r--r--llvm/lib/Analysis/LoopAccessAnalysis.cpp10
2 files changed, 11 insertions, 2 deletions
diff --git a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
index 717076a233b..795f4cd746d 100644
--- a/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
+++ b/llvm/include/llvm/Analysis/LoopAccessAnalysis.h
@@ -321,6 +321,9 @@ private:
/// \brief Check whether the data dependence could prevent store-load
/// forwarding.
+ ///
+ /// \return false if we shouldn't vectorize at all or avoid larger
+ /// vectorization factors by limiting MaxSafeDepDistBytes.
bool couldPreventStoreLoadForward(unsigned Distance, unsigned TypeByteSize);
};
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
index eff8b2a613c..0b41da5bbe1 100644
--- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp
+++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp
@@ -1081,14 +1081,20 @@ bool MemoryDepChecker::couldPreventStoreLoadForward(unsigned Distance,
// hence on your typical architecture store-load forwarding does not take
// place. Vectorizing in such cases does not make sense.
// Store-load forwarding distance.
- const unsigned NumCyclesForStoreLoadThroughMemory = 8 * TypeByteSize;
+
+ // After this many iterations store-to-load forwarding conflicts should not
+ // cause any slowdowns.
+ const unsigned NumItersForStoreLoadThroughMemory = 8 * TypeByteSize;
// Maximum vector factor.
unsigned MaxVFWithoutSLForwardIssues = std::min(
VectorizerParams::MaxVectorWidth * TypeByteSize, MaxSafeDepDistBytes);
+ // Compute the smallest VF at which the store and load would be misaligned.
for (unsigned VF = 2 * TypeByteSize; VF <= MaxVFWithoutSLForwardIssues;
VF *= 2) {
- if (Distance % VF && Distance / VF < NumCyclesForStoreLoadThroughMemory) {
+ // If the number of vector iteration between the store and the load are
+ // small we could incur conflicts.
+ if (Distance % VF && Distance / VF < NumItersForStoreLoadThroughMemory) {
MaxVFWithoutSLForwardIssues = (VF >>= 1);
break;
}
OpenPOWER on IntegriCloud