Index: lib/Transforms/Vectorize/LoopVectorize.cpp =================================================================== --- lib/Transforms/Vectorize/LoopVectorize.cpp +++ lib/Transforms/Vectorize/LoopVectorize.cpp @@ -570,43 +570,6 @@ } 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, 2> Pointers; - /// Holds the pointer value at the beginning of the loop. - SmallVector Starts; - /// Holds the pointer value at the end of the loop. - SmallVector Ends; - /// Holds the information if this pointer is used for writing to memory. - SmallVector IsWritePtr; - /// Holds the id of the set of pointers that could be dependent because of a - /// shared underlying object. - SmallVector DependencySetId; - /// Holds the id of the disjoint alias set to which this pointer belongs. - SmallVector AliasSetId; -}; - /// \brief Drive the analysis of memory accesses in the loop /// /// This class is responsible for analyzing the memory accesses of a loop. It @@ -647,6 +610,43 @@ 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, 2> Pointers; + /// Holds the pointer value at the beginning of the loop. + SmallVector Starts; + /// Holds the pointer value at the end of the loop. + SmallVector Ends; + /// Holds the information if this pointer is used for writing to memory. + SmallVector IsWritePtr; + /// Holds the id of the set of pointers that could be dependent because of a + /// shared underlying object. + SmallVector DependencySetId; + /// Holds the id of the disjoint alias set to which this pointer belongs. + SmallVector AliasSetId; + }; + LoopAccessAnalysis(Function *F, Loop *L, ScalarEvolution *SE, const DataLayout *DL, const TargetLibraryInfo *TLI, AliasAnalysis *AA, DominatorTree *DT, @@ -906,7 +906,7 @@ 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(); } @@ -1707,9 +1707,12 @@ 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(Sc); @@ -2235,7 +2238,8 @@ std::pair InnerLoopVectorizer::addRuntimeCheck(Instruction *Loc) { - RuntimePointerCheck *PtrRtCheck = Legal->getRuntimePointerCheck(); + LoopAccessAnalysis::RuntimePointerCheck *PtrRtCheck = + Legal->getRuntimePointerCheck(); Instruction *tnullptr = nullptr; if (!PtrRtCheck->Need) @@ -4169,7 +4173,8 @@ /// \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); @@ -4236,7 +4241,7 @@ 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