[llvm] r229625 - [LoopAccesses] Make blockNeedsPredication static
Adam Nemet
anemet at apple.com
Tue Feb 17 19:43:20 PST 2015
Author: anemet
Date: Tue Feb 17 21:43:19 2015
New Revision: 229625
URL: http://llvm.org/viewvc/llvm-project?rev=229625&view=rev
Log:
[LoopAccesses] Make blockNeedsPredication static
blockNeedsPredication is in LoopAccess in order to share it with the
vectorizer. It's a utility needed by LoopAccess not strictly provided
by it but it's a good place to share it. This makes the function static
so that it no longer required to create an LoopAccessInfo instance in
order to access it from LV.
This was actually causing problems because it would have required
creating LAI much earlier that LV::canVectorizeMemory().
This is part of the patchset that converts LoopAccessAnalysis into an
actual analysis pass.
Modified:
llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h
llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp
llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
Modified: llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h?rev=229625&r1=229624&r2=229625&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h (original)
+++ llvm/trunk/include/llvm/Analysis/LoopAccessAnalysis.h Tue Feb 17 21:43:19 2015
@@ -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);
Modified: llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp?rev=229625&r1=229624&r2=229625&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp (original)
+++ llvm/trunk/lib/Analysis/LoopAccessAnalysis.cpp Tue Feb 17 21:43:19 2015
@@ -931,7 +931,7 @@ void LoopAccessInfo::analyzeLoop(ValueTo
// 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(ValueTo
// 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(ValueTo
" 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.
Modified: llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp?rev=229625&r1=229624&r2=229625&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp (original)
+++ llvm/trunk/lib/Transforms/Vectorize/LoopVectorize.cpp Tue Feb 17 21:43:19 2015
@@ -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::isInduct
}
bool LoopVectorizationLegality::blockNeedsPredication(BasicBlock *BB) {
- return LAI.blockNeedsPredication(BB);
+ return LoopAccessInfo::blockNeedsPredication(BB, TheLoop, DT);
}
bool LoopVectorizationLegality::blockCanBePredicated(BasicBlock *BB,
More information about the llvm-commits
mailing list