diff options
author | Andreas Bolka <a@bolka.at> | 2009-08-03 01:03:48 +0000 |
---|---|---|
committer | Andreas Bolka <a@bolka.at> | 2009-08-03 01:03:48 +0000 |
commit | 5eca4525f42a99eec29be1676a7a77928853c521 (patch) | |
tree | 2845d54dc429acaabf9790a88cf988999cd87d49 /lib/Analysis/LoopDependenceAnalysis.cpp | |
parent | 275872e79950dafc6699f6502cee52f74b84a22a (diff) | |
download | external_llvm-5eca4525f42a99eec29be1676a7a77928853c521.zip external_llvm-5eca4525f42a99eec29be1676a7a77928853c521.tar.gz external_llvm-5eca4525f42a99eec29be1676a7a77928853c521.tar.bz2 |
Restrict LDA to affine subscripts.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@77932 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/LoopDependenceAnalysis.cpp')
-rw-r--r-- | lib/Analysis/LoopDependenceAnalysis.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Analysis/LoopDependenceAnalysis.cpp b/lib/Analysis/LoopDependenceAnalysis.cpp index 0c8bbd7..bf3978e 100644 --- a/lib/Analysis/LoopDependenceAnalysis.cpp +++ b/lib/Analysis/LoopDependenceAnalysis.cpp @@ -25,6 +25,7 @@ #include "llvm/Analysis/LoopDependenceAnalysis.h" #include "llvm/Analysis/LoopPass.h" #include "llvm/Analysis/ScalarEvolution.h" +#include "llvm/Analysis/ScalarEvolutionExpressions.h" #include "llvm/Instructions.h" #include "llvm/Operator.h" #include "llvm/Support/Allocator.h" @@ -123,6 +124,18 @@ bool LoopDependenceAnalysis::findOrInsertDependencePair(Value *A, return false; } +bool LoopDependenceAnalysis::isLoopInvariant(const SCEV *S) const { + for (const Loop *L = this->L; L != 0; L = L->getParentLoop()) + if (!S->isLoopInvariant(L)) + return false; + return true; +} + +bool LoopDependenceAnalysis::isAffine(const SCEV *S) const { + const SCEVAddRecExpr *rec = dyn_cast<SCEVAddRecExpr>(S); + return isLoopInvariant(S) || (rec && rec->isAffine()); +} + LoopDependenceAnalysis::DependenceResult LoopDependenceAnalysis::analyseSubscript(const SCEV *A, const SCEV *B, @@ -134,6 +147,11 @@ LoopDependenceAnalysis::analyseSubscript(const SCEV *A, return Dependent; } + if (!isAffine(A) || !isAffine(B)) { + DEBUG(errs() << " -> [?] not affine\n"); + return Unknown; + } + // TODO: Implement ZIV/SIV/MIV testers. DEBUG(errs() << " -> [?] cannot analyse subscript\n"); |