summaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorAndreas Bolka <a@bolka.at>2009-08-07 18:23:41 +0000
committerAndreas Bolka <a@bolka.at>2009-08-07 18:23:41 +0000
commit699db99c1a356eaa407ee03ebdf8553853d82bbd (patch)
tree0d7e53f9cdd366391ed4beebcb7daf0cc6272a08 /lib/Analysis
parent1c5a28706d0b2e712f4c825d638b46bbe6eb67d6 (diff)
downloadllvm-699db99c1a356eaa407ee03ebdf8553853d82bbd.tar.gz
llvm-699db99c1a356eaa407ee03ebdf8553853d82bbd.tar.bz2
llvm-699db99c1a356eaa407ee03ebdf8553853d82bbd.tar.xz
SIV/MIV classification for LDA.
LoopDependenceAnalysis::getLoops is currently O(N*M) for a loop-nest of depth N and a compound SCEV of M atomic SCEVs. As both N and M will typically be very small, this should not be a problem. If it turns out to be one, rewriting getLoops as SCEVVisitor will reduce complexity to O(M). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78394 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis')
-rw-r--r--lib/Analysis/LoopDependenceAnalysis.cpp41
1 files changed, 35 insertions, 6 deletions
diff --git a/lib/Analysis/LoopDependenceAnalysis.cpp b/lib/Analysis/LoopDependenceAnalysis.cpp
index eb8ea0ebdb..d37273c372 100644
--- a/lib/Analysis/LoopDependenceAnalysis.cpp
+++ b/lib/Analysis/LoopDependenceAnalysis.cpp
@@ -20,6 +20,7 @@
//===----------------------------------------------------------------------===//
#define DEBUG_TYPE "lda"
+#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/LoopDependenceAnalysis.h"
@@ -124,11 +125,18 @@ bool LoopDependenceAnalysis::findOrInsertDependencePair(Value *A,
return false;
}
-bool LoopDependenceAnalysis::isLoopInvariant(const SCEV *S) const {
+void LoopDependenceAnalysis::getLoops(const SCEV *S,
+ DenseSet<const Loop*>* Loops) const {
+ // Refactor this into an SCEVVisitor, if efficiency becomes a concern.
for (const Loop *L = this->L; L != 0; L = L->getParentLoop())
if (!S->isLoopInvariant(L))
- return false;
- return true;
+ Loops->insert(L);
+}
+
+bool LoopDependenceAnalysis::isLoopInvariant(const SCEV *S) const {
+ DenseSet<const Loop*> loops;
+ getLoops(S, &loops);
+ return loops.empty();
}
bool LoopDependenceAnalysis::isAffine(const SCEV *S) const {
@@ -140,6 +148,13 @@ bool LoopDependenceAnalysis::isZIVPair(const SCEV *A, const SCEV *B) const {
return isLoopInvariant(A) && isLoopInvariant(B);
}
+bool LoopDependenceAnalysis::isSIVPair(const SCEV *A, const SCEV *B) const {
+ DenseSet<const Loop*> loops;
+ getLoops(A, &loops);
+ getLoops(B, &loops);
+ return loops.size() == 1;
+}
+
LoopDependenceAnalysis::DependenceResult
LoopDependenceAnalysis::analyseZIV(const SCEV *A,
const SCEV *B,
@@ -149,6 +164,20 @@ LoopDependenceAnalysis::analyseZIV(const SCEV *A,
}
LoopDependenceAnalysis::DependenceResult
+LoopDependenceAnalysis::analyseSIV(const SCEV *A,
+ const SCEV *B,
+ Subscript *S) const {
+ return Unknown; // TODO: Implement.
+}
+
+LoopDependenceAnalysis::DependenceResult
+LoopDependenceAnalysis::analyseMIV(const SCEV *A,
+ const SCEV *B,
+ Subscript *S) const {
+ return Unknown; // TODO: Implement.
+}
+
+LoopDependenceAnalysis::DependenceResult
LoopDependenceAnalysis::analyseSubscript(const SCEV *A,
const SCEV *B,
Subscript *S) const {
@@ -167,10 +196,10 @@ LoopDependenceAnalysis::analyseSubscript(const SCEV *A,
if (isZIVPair(A, B))
return analyseZIV(A, B, S);
- // TODO: Implement SIV/MIV testers.
+ if (isSIVPair(A, B))
+ return analyseSIV(A, B, S);
- DEBUG(errs() << " -> [?] cannot analyse subscript\n");
- return Unknown;
+ return analyseMIV(A, B, S);
}
LoopDependenceAnalysis::DependenceResult