summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Bolka <a@bolka.at>2009-08-05 04:26:05 +0000
committerAndreas Bolka <a@bolka.at>2009-08-05 04:26:05 +0000
commit831f6f6d2ae5a1ad988c8328404b052b7985ce31 (patch)
treed46d7b70cb5ace9f6ec717b9731e1728a499e686
parent58bed8fc29b6e55e7014dcb537808043c946cd73 (diff)
downloadllvm-831f6f6d2ae5a1ad988c8328404b052b7985ce31.tar.gz
llvm-831f6f6d2ae5a1ad988c8328404b052b7985ce31.tar.bz2
llvm-831f6f6d2ae5a1ad988c8328404b052b7985ce31.tar.xz
ZIV tester for LDA.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78157 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/Analysis/LoopDependenceAnalysis.h2
-rw-r--r--lib/Analysis/LoopDependenceAnalysis.cpp18
-rw-r--r--test/Analysis/LoopDependenceAnalysis/alias.ll2
-rw-r--r--test/Analysis/LoopDependenceAnalysis/ziv.ll4
4 files changed, 22 insertions, 4 deletions
diff --git a/include/llvm/Analysis/LoopDependenceAnalysis.h b/include/llvm/Analysis/LoopDependenceAnalysis.h
index b43eeda728..236f79ae97 100644
--- a/include/llvm/Analysis/LoopDependenceAnalysis.h
+++ b/include/llvm/Analysis/LoopDependenceAnalysis.h
@@ -77,6 +77,8 @@ class LoopDependenceAnalysis : public LoopPass {
bool isAffine(const SCEV*) const;
/// TODO: doc
+ bool isZIVPair(const SCEV*, const SCEV*) const;
+ DependenceResult analyseZIV(const SCEV*, const SCEV*, Subscript*) const;
DependenceResult analyseSubscript(const SCEV*, const SCEV*, Subscript*) const;
DependenceResult analysePair(DependencePair*) const;
diff --git a/lib/Analysis/LoopDependenceAnalysis.cpp b/lib/Analysis/LoopDependenceAnalysis.cpp
index 5d593a97bf..10a6a8eb06 100644
--- a/lib/Analysis/LoopDependenceAnalysis.cpp
+++ b/lib/Analysis/LoopDependenceAnalysis.cpp
@@ -136,6 +136,19 @@ bool LoopDependenceAnalysis::isAffine(const SCEV *S) const {
return isLoopInvariant(S) || (rec && rec->isAffine());
}
+bool LoopDependenceAnalysis::isZIVPair(const SCEV *A, const SCEV *B) const {
+ return isLoopInvariant(A) && isLoopInvariant(B);
+}
+
+LoopDependenceAnalysis::DependenceResult
+LoopDependenceAnalysis::analyseZIV(const SCEV *A,
+ const SCEV *B,
+ Subscript *S) const {
+ assert(isZIVPair(A, B));
+ const SCEV *diff = SE->getMinusSCEV(A, B);
+ return diff->isZero() ? Dependent : Independent;
+}
+
LoopDependenceAnalysis::DependenceResult
LoopDependenceAnalysis::analyseSubscript(const SCEV *A,
const SCEV *B,
@@ -152,7 +165,10 @@ LoopDependenceAnalysis::analyseSubscript(const SCEV *A,
return Unknown;
}
- // TODO: Implement ZIV/SIV/MIV testers.
+ if (isZIVPair(A, B))
+ return analyseZIV(A, B, S);
+
+ // TODO: Implement SIV/MIV testers.
DEBUG(errs() << " -> [?] cannot analyse subscript\n");
return Unknown;
diff --git a/test/Analysis/LoopDependenceAnalysis/alias.ll b/test/Analysis/LoopDependenceAnalysis/alias.ll
index b6a5a4fc37..46d38af280 100644
--- a/test/Analysis/LoopDependenceAnalysis/alias.ll
+++ b/test/Analysis/LoopDependenceAnalysis/alias.ll
@@ -34,7 +34,7 @@ for.body:
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
%x = load i32* %x.ld.addr
store i32 %x, i32* %x.st.addr
-; CHECK: 0,1: dep
+; CHECK: 0,1: ind
%i.next = add i64 %i, 1
%exitcond = icmp eq i64 %i.next, 256
br i1 %exitcond, label %for.end, label %for.body
diff --git a/test/Analysis/LoopDependenceAnalysis/ziv.ll b/test/Analysis/LoopDependenceAnalysis/ziv.ll
index d0235aebc3..3b265ba273 100644
--- a/test/Analysis/LoopDependenceAnalysis/ziv.ll
+++ b/test/Analysis/LoopDependenceAnalysis/ziv.ll
@@ -12,7 +12,7 @@ for.body:
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
%x = load i32* getelementptr ([256 x i32]* @x, i32 0, i64 6)
store i32 %x, i32* getelementptr ([256 x i32]* @x, i32 0, i64 5)
-; CHECK: 0,1: dep
+; CHECK: 0,1: ind
%i.next = add i64 %i, 1
%exitcond = icmp eq i64 %i.next, 256
br i1 %exitcond, label %for.end, label %for.body
@@ -34,7 +34,7 @@ for.body:
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
%x = load i32* %x.ld.addr
store i32 %x, i32* %x.st.addr
-; CHECK: 0,1: dep
+; CHECK: 0,1: ind
%i.next = add i64 %i, 1
%exitcond = icmp eq i64 %i.next, 256
br i1 %exitcond, label %for.end, label %for.body