ZIV tester for LDA.
authorAndreas Bolka <a@bolka.at>
Wed, 5 Aug 2009 04:26:05 +0000 (04:26 +0000)
committerAndreas Bolka <a@bolka.at>
Wed, 5 Aug 2009 04:26:05 +0000 (04:26 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78157 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/LoopDependenceAnalysis.h
lib/Analysis/LoopDependenceAnalysis.cpp
test/Analysis/LoopDependenceAnalysis/alias.ll
test/Analysis/LoopDependenceAnalysis/ziv.ll

index b43eeda7288d62ee377fef822027f4341204d4f2..236f79ae9706541423a099b24f50ee4f73a5029f 100644 (file)
@@ -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;
 
index 5d593a97bf3314c6c12dd96f1486bcf5fb8046a2..10a6a8eb06f500bdedbf6909a32526ac9d04777f 100644 (file)
@@ -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;
index b6a5a4fc377ad23dfe63ca67af2a97983c4c1b9c..46d38af280eb606a5e3f1ccc57a551bf86f8ab47 100644 (file)
@@ -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
index d0235aebc31c403d1b19822e2365d223de762c7c..3b265ba2733499b2efbfbaa12dbef6c2af71eaef 100644 (file)
@@ -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