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 MemAccessInfo; typedef SmallPtrSet 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(),