[llvm] r227747 - [LoopVectorize] Split out RuntimePointerCheck from LoopVectorizationLegality

Adam Nemet anemet at apple.com
Sun Feb 1 08:55:57 PST 2015


Author: anemet
Date: Sun Feb  1 10:55:56 2015
New Revision: 227747

URL: http://llvm.org/viewvc/llvm-project?rev=227747&view=rev
Log:
[LoopVectorize] Split out RuntimePointerCheck from LoopVectorizationLegality

RuntimePointerCheck will be used through LoopAccessAnalysis in
LoopVectorizationLegality.  Later in the patchset it will become a local class
of LoopAccessAnalysis.

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=227747&r1=227746&r2=227747&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Sun Feb  1 10:55:56 2015
@@ -558,6 +558,45 @@ static void propagateMetadata(SmallVecto
       propagateMetadata(I, From);
 }
 
+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;
+};
+} // end anonymous namespace
+
 /// LoopVectorizationLegality checks if it is legal to vectorize a loop, and
 /// to what vectorization factor.
 /// This class does not look at the profitability of vectorization, only the
@@ -655,43 +694,6 @@ public:
     MinMaxReductionKind MinMaxKind;
   };
 
-  /// 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;
-  };
-
   /// A struct for saving information about induction variables.
   struct InductionInfo {
     InductionInfo(Value *Start, InductionKind K, ConstantInt *Step)
@@ -1608,9 +1610,9 @@ static const SCEV *replaceSymbolicStride
   return SE->getSCEV(Ptr);
 }
 
-void LoopVectorizationLegality::RuntimePointerCheck::insert(
-    ScalarEvolution *SE, Loop *Lp, Value *Ptr, bool WritePtr, unsigned DepSetId,
-    unsigned ASId, ValueToValueMap &Strides) {
+void 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);
@@ -2132,8 +2134,7 @@ InnerLoopVectorizer::addStrideCheck(Inst
 
 std::pair<Instruction *, Instruction *>
 InnerLoopVectorizer::addRuntimeCheck(Instruction *Loc) {
-  LoopVectorizationLegality::RuntimePointerCheck *PtrRtCheck =
-  Legal->getRuntimePointerCheck();
+  RuntimePointerCheck *PtrRtCheck = Legal->getRuntimePointerCheck();
 
   Instruction *tnullptr = nullptr;
   if (!PtrRtCheck->Need)
@@ -4066,9 +4067,9 @@ public:
 
   /// \brief Check whether we can check the pointers at runtime for
   /// non-intersection.
-  bool canCheckPtrAtRT(LoopVectorizationLegality::RuntimePointerCheck &RtCheck,
-                       unsigned &NumComparisons, ScalarEvolution *SE,
-                       Loop *TheLoop, ValueToValueMap &Strides,
+  bool canCheckPtrAtRT(RuntimePointerCheck &RtCheck, unsigned &NumComparisons,
+                       ScalarEvolution *SE, Loop *TheLoop,
+                       ValueToValueMap &Strides,
                        bool ShouldCheckStride = false);
 
   /// \brief Goes over all memory accesses, checks whether a RT check is needed
@@ -4133,7 +4134,7 @@ static int isStridedPtr(ScalarEvolution
                         const Loop *Lp, ValueToValueMap &StridesMap);
 
 bool AccessAnalysis::canCheckPtrAtRT(
-    LoopVectorizationLegality::RuntimePointerCheck &RtCheck,
+    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