[llvm] r227755 - [LoopVectorize] Move RuntimePointerCheck under LoopAccessAnalysis

Adam Nemet anemet at apple.com
Sun Feb 1 08:56:12 PST 2015


Author: anemet
Date: Sun Feb  1 10:56:11 2015
New Revision: 227755

URL: http://llvm.org/viewvc/llvm-project?rev=227755&view=rev
Log:
[LoopVectorize] Move RuntimePointerCheck under LoopAccessAnalysis

This class needs to remain public because it's used by
LoopVectorizationLegality::addRuntimeCheck.

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.

Modified:
    llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp

Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=227755&r1=227754&r2=227755&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Sun Feb  1 10:56:11 2015
@@ -575,43 +575,6 @@ static void propagateMetadata(SmallVecto
 }
 
 namespace {
-/// This struct holds information about the memory runtime legality
-/// check that a group of pointers do not overlap.
-struct RuntimePointerCheck {
-  RuntimePointerCheck() : Need(false) {}
-
-  /// Reset the state of the pointer runtime information.
-  void reset() {
-    Need = false;
-    Pointers.clear();
-    Starts.clear();
-    Ends.clear();
-    IsWritePtr.clear();
-    DependencySetId.clear();
-    AliasSetId.clear();
-  }
-
-  /// Insert a pointer and calculate the start and end SCEVs.
-  void insert(ScalarEvolution *SE, Loop *Lp, Value *Ptr, bool WritePtr,
-              unsigned DepSetId, unsigned ASId, ValueToValueMap &Strides);
-
-  /// This flag indicates if we need to add the runtime check.
-  bool Need;
-  /// Holds the pointers that we need to check.
-  SmallVector<TrackingVH<Value>, 2> Pointers;
-  /// Holds the pointer value at the beginning of the loop.
-  SmallVector<const SCEV*, 2> Starts;
-  /// Holds the pointer value at the end of the loop.
-  SmallVector<const SCEV*, 2> Ends;
-  /// Holds the information if this pointer is used for writing to memory.
-  SmallVector<bool, 2> IsWritePtr;
-  /// Holds the id of the set of pointers that could be dependent because of a
-  /// shared underlying object.
-  SmallVector<unsigned, 2> DependencySetId;
-  /// Holds the id of the disjoint alias set to which this pointer belongs.
-  SmallVector<unsigned, 2> AliasSetId;
-};
-
 /// \brief Drive the analysis of memory accesses in the loop
 ///
 /// This class is responsible for analyzing the memory accesses of a loop.  It
@@ -652,6 +615,43 @@ public:
         RuntimeMemoryCheckThreshold(RuntimeMemoryCheckThreshold) {}
   };
 
+  /// This struct holds information about the memory runtime legality check that
+  /// a group of pointers do not overlap.
+  struct RuntimePointerCheck {
+    RuntimePointerCheck() : Need(false) {}
+
+    /// Reset the state of the pointer runtime information.
+    void reset() {
+      Need = false;
+      Pointers.clear();
+      Starts.clear();
+      Ends.clear();
+      IsWritePtr.clear();
+      DependencySetId.clear();
+      AliasSetId.clear();
+    }
+
+    /// Insert a pointer and calculate the start and end SCEVs.
+    void insert(ScalarEvolution *SE, Loop *Lp, Value *Ptr, bool WritePtr,
+                unsigned DepSetId, unsigned ASId, ValueToValueMap &Strides);
+
+    /// This flag indicates if we need to add the runtime check.
+    bool Need;
+    /// Holds the pointers that we need to check.
+    SmallVector<TrackingVH<Value>, 2> Pointers;
+    /// Holds the pointer value at the beginning of the loop.
+    SmallVector<const SCEV*, 2> Starts;
+    /// Holds the pointer value at the end of the loop.
+    SmallVector<const SCEV*, 2> Ends;
+    /// Holds the information if this pointer is used for writing to memory.
+    SmallVector<bool, 2> IsWritePtr;
+    /// Holds the id of the set of pointers that could be dependent because of a
+    /// shared underlying object.
+    SmallVector<unsigned, 2> DependencySetId;
+    /// Holds the id of the disjoint alias set to which this pointer belongs.
+    SmallVector<unsigned, 2> AliasSetId;
+  };
+
   LoopAccessAnalysis(Function *F, Loop *L, ScalarEvolution *SE,
                      const DataLayout *DL, const TargetLibraryInfo *TLI,
                      AliasAnalysis *AA, DominatorTree *DT,
@@ -911,7 +911,7 @@ public:
   bool isUniformAfterVectorization(Instruction* I) { return Uniforms.count(I); }
 
   /// Returns the information that we collected about runtime memory check.
-  RuntimePointerCheck *getRuntimePointerCheck() {
+  LoopAccessAnalysis::RuntimePointerCheck *getRuntimePointerCheck() {
     return LAA.getRuntimePointerCheck();
   }
 
@@ -1712,9 +1712,12 @@ static const SCEV *replaceSymbolicStride
   return SE->getSCEV(Ptr);
 }
 
-void RuntimePointerCheck::insert(ScalarEvolution *SE, Loop *Lp, Value *Ptr,
-                                 bool WritePtr, unsigned DepSetId,
-                                 unsigned ASId, ValueToValueMap &Strides) {
+void LoopAccessAnalysis::RuntimePointerCheck::insert(ScalarEvolution *SE,
+                                                     Loop *Lp, Value *Ptr,
+                                                     bool WritePtr,
+                                                     unsigned DepSetId,
+                                                     unsigned ASId,
+                                                     ValueToValueMap &Strides) {
   // Get the stride replaced scev.
   const SCEV *Sc = replaceSymbolicStrideSCEV(SE, Strides, Ptr);
   const SCEVAddRecExpr *AR = dyn_cast<SCEVAddRecExpr>(Sc);
@@ -2240,7 +2243,8 @@ InnerLoopVectorizer::addStrideCheck(Inst
 
 std::pair<Instruction *, Instruction *>
 InnerLoopVectorizer::addRuntimeCheck(Instruction *Loc) {
-  RuntimePointerCheck *PtrRtCheck = Legal->getRuntimePointerCheck();
+  LoopAccessAnalysis::RuntimePointerCheck *PtrRtCheck =
+    Legal->getRuntimePointerCheck();
 
   Instruction *tnullptr = nullptr;
   if (!PtrRtCheck->Need)
@@ -4185,7 +4189,8 @@ public:
 
   /// \brief Check whether we can check the pointers at runtime for
   /// non-intersection.
-  bool canCheckPtrAtRT(RuntimePointerCheck &RtCheck, unsigned &NumComparisons,
+  bool canCheckPtrAtRT(LoopAccessAnalysis::RuntimePointerCheck &RtCheck,
+                       unsigned &NumComparisons,
                        ScalarEvolution *SE, Loop *TheLoop,
                        ValueToValueMap &Strides,
                        bool ShouldCheckStride = false);
@@ -4252,7 +4257,7 @@ static int isStridedPtr(ScalarEvolution
                         const Loop *Lp, ValueToValueMap &StridesMap);
 
 bool AccessAnalysis::canCheckPtrAtRT(
-    RuntimePointerCheck &RtCheck,
+    LoopAccessAnalysis::RuntimePointerCheck &RtCheck,
     unsigned &NumComparisons, ScalarEvolution *SE, Loop *TheLoop,
     ValueToValueMap &StridesMap, bool ShouldCheckStride) {
   // Find pointers with computable bounds. We are going to use this information





More information about the llvm-commits mailing list