[PATCH] [LoopVectorize] Pass parameters explicitly to MemoryDepChecker

Adam Nemet anemet at apple.com
Thu Jan 29 16:53:15 PST 2015


Hi hfinkel, aschwaighofer,

Rather than using globals.  This prepares the class to be moved outside the
LoopVectorizer.

It's not great how all these are passed through in LoopAccessAnalysis but this
is all expected to change once the class start servicing the Loop Distribution
pass as well where these parameters make no sense.

NFC.  This is part of the patchset that splits out the memory dependence logic
from LoopVectorizationLegality into a new class LoopAccessAnalysis.
LoopAccessAnalysis will be used by the new Loop Distribution pass.

http://reviews.llvm.org/D7284

Files:
  lib/Transforms/Vectorize/LoopVectorize.cpp

Index: lib/Transforms/Vectorize/LoopVectorize.cpp
===================================================================
--- lib/Transforms/Vectorize/LoopVectorize.cpp
+++ lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -626,9 +626,15 @@
 public:
   LoopAccessAnalysis(Function *F, Loop *L, ScalarEvolution *SE,
                      const DataLayout *DL, const TargetLibraryInfo *TLI,
-                     AliasAnalysis *AA, DominatorTree *DT) :
+                     AliasAnalysis *AA, DominatorTree *DT,
+                     unsigned MaxVectorWidth, unsigned VectorizationFactor,
+                     unsigned VectorizationInterleave,
+                     unsigned RuntimeMemoryCheckThreshold) :
       TheFunction(F), TheLoop(L), SE(SE), DL(DL), TLI(TLI), AA(AA), DT(DT),
-      NumLoads(0), NumStores(0), MaxSafeDepDistBytes(-1U) {
+      NumLoads(0), NumStores(0), MaxSafeDepDistBytes(-1U),
+      MaxVectorWidth(MaxVectorWidth), VectorizationFactor(VectorizationFactor),
+      VectorizationInterleave(VectorizationInterleave),
+      RuntimeMemoryCheckThreshold(RuntimeMemoryCheckThreshold) {
   }
 
   /// Return true we can analyze the memory accesses in the loop and there are
@@ -666,6 +672,18 @@
   unsigned NumStores;
 
   unsigned MaxSafeDepDistBytes;
+
+  /// \brief Maximum simd width.
+  unsigned MaxVectorWidth;
+
+  /// \brief VF as overridden by the user.
+  unsigned VectorizationFactor;
+  /// \brief Interleave factor as overridden by the user.
+  unsigned VectorizationInterleave;
+
+  /// \\brief When performing memory disambiguation checks at runtime do not
+  /// make more than this number of comparisons.
+  unsigned RuntimeMemoryCheckThreshold;
 };
 
 /// LoopVectorizationLegality checks if it is legal to vectorize a loop, and
@@ -689,7 +707,9 @@
                             const TargetTransformInfo *TTI)
       : NumPredStores(0), TheLoop(L), SE(SE), DL(DL), TLI(TLI), TheFunction(F),
         TTI(TTI), Induction(nullptr), WidestIndTy(nullptr),
-        LAA(F, L, SE, DL, TLI, AA, DT), HasFunNoNaNAttr(false) {
+        LAA(F, L, SE, DL, TLI, AA, DT, MaxVectorWidth, VectorizationFactor,
+            VectorizationInterleave, RuntimeMemoryCheckThreshold),
+        HasFunNoNaNAttr(false) {
   }
 
   /// This enum represents the kinds of reductions that we support.
@@ -4446,9 +4466,13 @@
   typedef PointerIntPair<Value *, 1, bool> MemAccessInfo;
   typedef SmallPtrSet<MemAccessInfo, 8> MemAccessInfoSet;
 
-  MemoryDepChecker(ScalarEvolution *Se, const DataLayout *Dl, const Loop *L)
+  MemoryDepChecker(ScalarEvolution *Se, const DataLayout *Dl, const Loop *L,
+                   unsigned MaxVectorWidth, unsigned VectorizationFactor,
+                   unsigned VectorizationInterleave)
       : SE(Se), DL(Dl), InnermostLoop(L), AccessIdx(0),
-        ShouldRetryWithRuntimeCheck(false) {}
+        ShouldRetryWithRuntimeCheck(false), MaxVectorWidth(MaxVectorWidth),
+        VectorizationFactor(VectorizationFactor),
+        VectorizationInterleave(VectorizationInterleave) {}
 
   /// \brief Register the location (instructions are given increasing numbers)
   /// of a write access.
@@ -4503,6 +4527,14 @@
   /// vectorize this loop with runtime checks.
   bool ShouldRetryWithRuntimeCheck;
 
+  /// \brief Maximum simd width.
+  unsigned MaxVectorWidth;
+
+  /// \brief VF as overridden by the user.
+  unsigned VectorizationFactor;
+  /// \brief Interleave factor as overridden by the user.
+  unsigned VectorizationInterleave;
+
   /// \brief Check whether there is a plausible dependence between the two
   /// accesses.
   ///
@@ -4834,7 +4866,8 @@
   PtrRtCheck.Need = false;
 
   const bool IsAnnotatedParallel = TheLoop->isAnnotatedParallel();
-  MemoryDepChecker DepChecker(SE, DL, TheLoop);
+  MemoryDepChecker DepChecker(SE, DL, TheLoop, MaxVectorWidth,
+                              VectorizationFactor, VectorizationInterleave);
 
   // For each block.
   for (Loop::block_iterator bb = TheLoop->block_begin(),

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7284.19013.patch
Type: text/x-patch
Size: 3975 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150130/bb8df3cb/attachment.bin>


More information about the llvm-commits mailing list