aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/LoopDependenceAnalysis.cpp
diff options
context:
space:
mode:
authorAndreas Bolka <a@bolka.at>2009-08-03 01:03:48 +0000
committerAndreas Bolka <a@bolka.at>2009-08-03 01:03:48 +0000
commitc833d017c7fe3fad76f3e54c2d214c1266997eec (patch)
treef658e36d00eb07d35eca00777cf108ff925bdd1a /llvm/lib/Analysis/LoopDependenceAnalysis.cpp
parentf72c0d6b19b4b28915b4431ea7a59b4ff8ec6df0 (diff)
downloadllvm-c833d017c7fe3fad76f3e54c2d214c1266997eec.zip
llvm-c833d017c7fe3fad76f3e54c2d214c1266997eec.tar.gz
llvm-c833d017c7fe3fad76f3e54c2d214c1266997eec.tar.bz2
Restrict LDA to affine subscripts.
llvm-svn: 77932
Diffstat (limited to 'llvm/lib/Analysis/LoopDependenceAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/LoopDependenceAnalysis.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LoopDependenceAnalysis.cpp b/llvm/lib/Analysis/LoopDependenceAnalysis.cpp
index 0c8bbd7..bf3978e 100644
--- a/llvm/lib/Analysis/LoopDependenceAnalysis.cpp
+++ b/llvm/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");