Skip to content

Commit 13b8609

Browse files
committed
ZIV tester for LDA.
llvm-svn: 78157
1 parent cbc7b26 commit 13b8609

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

llvm/include/llvm/Analysis/LoopDependenceAnalysis.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ class LoopDependenceAnalysis : public LoopPass {
7777
bool isAffine(const SCEV*) const;
7878

7979
/// TODO: doc
80+
bool isZIVPair(const SCEV*, const SCEV*) const;
81+
DependenceResult analyseZIV(const SCEV*, const SCEV*, Subscript*) const;
8082
DependenceResult analyseSubscript(const SCEV*, const SCEV*, Subscript*) const;
8183
DependenceResult analysePair(DependencePair*) const;
8284

llvm/lib/Analysis/LoopDependenceAnalysis.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ bool LoopDependenceAnalysis::isAffine(const SCEV *S) const {
136136
return isLoopInvariant(S) || (rec && rec->isAffine());
137137
}
138138

139+
bool LoopDependenceAnalysis::isZIVPair(const SCEV *A, const SCEV *B) const {
140+
return isLoopInvariant(A) && isLoopInvariant(B);
141+
}
142+
143+
LoopDependenceAnalysis::DependenceResult
144+
LoopDependenceAnalysis::analyseZIV(const SCEV *A,
145+
const SCEV *B,
146+
Subscript *S) const {
147+
assert(isZIVPair(A, B));
148+
const SCEV *diff = SE->getMinusSCEV(A, B);
149+
return diff->isZero() ? Dependent : Independent;
150+
}
151+
139152
LoopDependenceAnalysis::DependenceResult
140153
LoopDependenceAnalysis::analyseSubscript(const SCEV *A,
141154
const SCEV *B,
@@ -152,7 +165,10 @@ LoopDependenceAnalysis::analyseSubscript(const SCEV *A,
152165
return Unknown;
153166
}
154167

155-
// TODO: Implement ZIV/SIV/MIV testers.
168+
if (isZIVPair(A, B))
169+
return analyseZIV(A, B, S);
170+
171+
// TODO: Implement SIV/MIV testers.
156172

157173
DEBUG(errs() << " -> [?] cannot analyse subscript\n");
158174
return Unknown;

llvm/test/Analysis/LoopDependenceAnalysis/alias.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ for.body:
3434
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
3535
%x = load i32* %x.ld.addr
3636
store i32 %x, i32* %x.st.addr
37-
; CHECK: 0,1: dep
37+
; CHECK: 0,1: ind
3838
%i.next = add i64 %i, 1
3939
%exitcond = icmp eq i64 %i.next, 256
4040
br i1 %exitcond, label %for.end, label %for.body

llvm/test/Analysis/LoopDependenceAnalysis/ziv.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ for.body:
1212
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
1313
%x = load i32* getelementptr ([256 x i32]* @x, i32 0, i64 6)
1414
store i32 %x, i32* getelementptr ([256 x i32]* @x, i32 0, i64 5)
15-
; CHECK: 0,1: dep
15+
; CHECK: 0,1: ind
1616
%i.next = add i64 %i, 1
1717
%exitcond = icmp eq i64 %i.next, 256
1818
br i1 %exitcond, label %for.end, label %for.body
@@ -34,7 +34,7 @@ for.body:
3434
%i = phi i64 [ 0, %entry ], [ %i.next, %for.body ]
3535
%x = load i32* %x.ld.addr
3636
store i32 %x, i32* %x.st.addr
37-
; CHECK: 0,1: dep
37+
; CHECK: 0,1: ind
3838
%i.next = add i64 %i, 1
3939
%exitcond = icmp eq i64 %i.next, 256
4040
br i1 %exitcond, label %for.end, label %for.body

0 commit comments

Comments
 (0)