diff --git a/include/llvm/Analysis/LoopAccessAnalysis.h b/include/llvm/Analysis/LoopAccessAnalysis.h index 0cdde4c2564..3fbdb8bb851 100644 --- a/include/llvm/Analysis/LoopAccessAnalysis.h +++ b/include/llvm/Analysis/LoopAccessAnalysis.h @@ -147,7 +147,8 @@ public: /// Return true if the block BB needs to be predicated in order for the loop /// to be vectorized. - bool blockNeedsPredication(BasicBlock *BB); + static bool blockNeedsPredication(BasicBlock *BB, Loop *TheLoop, + DominatorTree *DT); /// Returns true if the value V is uniform within the loop. bool isUniform(Value *V); diff --git a/lib/Analysis/LoopAccessAnalysis.cpp b/lib/Analysis/LoopAccessAnalysis.cpp index 6ebb0eff812..ca6e7a83e57 100644 --- a/lib/Analysis/LoopAccessAnalysis.cpp +++ b/lib/Analysis/LoopAccessAnalysis.cpp @@ -931,7 +931,7 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) { // The TBAA metadata could have a control dependency on the predication // condition, so we cannot rely on it when determining whether or not we // need runtime pointer checks. - if (blockNeedsPredication(ST->getParent())) + if (blockNeedsPredication(ST->getParent(), TheLoop, DT)) Loc.AATags.TBAA = nullptr; Accesses.addStore(Loc); @@ -968,7 +968,7 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) { // The TBAA metadata could have a control dependency on the predication // condition, so we cannot rely on it when determining whether or not we // need runtime pointer checks. - if (blockNeedsPredication(LD->getParent())) + if (blockNeedsPredication(LD->getParent(), TheLoop, DT)) Loc.AATags.TBAA = nullptr; Accesses.addLoad(Loc, IsReadOnlyPtr); @@ -1075,7 +1075,8 @@ void LoopAccessInfo::analyzeLoop(ValueToValueMap &Strides) { " need a runtime memory check.\n"); } -bool LoopAccessInfo::blockNeedsPredication(BasicBlock *BB) { +bool LoopAccessInfo::blockNeedsPredication(BasicBlock *BB, Loop *TheLoop, + DominatorTree *DT) { assert(TheLoop->contains(BB) && "Unknown block used"); // Blocks that do not dominate the latch need predication. diff --git a/lib/Transforms/Vectorize/LoopVectorize.cpp b/lib/Transforms/Vectorize/LoopVectorize.cpp index 1def103d970..1dc4041a300 100644 --- a/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -554,7 +554,7 @@ public: AliasAnalysis *AA, Function *F, const TargetTransformInfo *TTI) : NumPredStores(0), TheLoop(L), SE(SE), DL(DL), - TLI(TLI), TheFunction(F), TTI(TTI), Induction(nullptr), + TLI(TLI), TheFunction(F), TTI(TTI), DT(DT), Induction(nullptr), WidestIndTy(nullptr), LAI(L, SE, DL, TLI, AA, DT), HasFunNoNaNAttr(false) {} @@ -855,6 +855,8 @@ private: Function *TheFunction; /// Target Transform Info const TargetTransformInfo *TTI; + /// Dominator Tree. + DominatorTree *DT; // --- vectorization state --- // @@ -4173,7 +4175,7 @@ bool LoopVectorizationLegality::isInductionVariable(const Value *V) { } bool LoopVectorizationLegality::blockNeedsPredication(BasicBlock *BB) { - return LAI.blockNeedsPredication(BB); + return LoopAccessInfo::blockNeedsPredication(BB, TheLoop, DT); } bool LoopVectorizationLegality::blockCanBePredicated(BasicBlock *BB,