[llvm-branch-commits] [llvm] 4a17b9a - [LAA] Add tests with uncomputable BTCs.

Florian Hahn via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri Jan 1 06:02:22 PST 2021


Author: Florian Hahn
Date: 2021-01-01T13:57:02Z
New Revision: 4a17b9a39b706f267837375370950a029130354e

URL: https://github.com/llvm/llvm-project/commit/4a17b9a39b706f267837375370950a029130354e
DIFF: https://github.com/llvm/llvm-project/commit/4a17b9a39b706f267837375370950a029130354e.diff

LOG: [LAA] Add tests with uncomputable BTCs.

Added: 
    llvm/test/Analysis/LoopAccessAnalysis/uncomputable-backedge-taken-count.ll

Modified: 
    llvm/test/Analysis/LoopAccessAnalysis/pointer-with-unknown-bounds.ll

Removed: 
    


################################################################################
diff  --git a/llvm/test/Analysis/LoopAccessAnalysis/pointer-with-unknown-bounds.ll b/llvm/test/Analysis/LoopAccessAnalysis/pointer-with-unknown-bounds.ll
index 2109a4d0ec4b..6cd7d4396e36 100644
--- a/llvm/test/Analysis/LoopAccessAnalysis/pointer-with-unknown-bounds.ll
+++ b/llvm/test/Analysis/LoopAccessAnalysis/pointer-with-unknown-bounds.ll
@@ -1,5 +1,5 @@
 ; RUN: opt -loop-accesses -analyze -enable-new-pm=0 < %s | FileCheck %s
-; RUN: opt -passes='require<scalar-evolution>,require<aa>,loop(print-access-info)' -disable-output  < %s 2>&1 | FileCheck %s
+; RUN: opt -aa-pipeline=basic-aa -passes='require<scalar-evolution>,require<aa>,loop(print-access-info)' -disable-output  < %s 2>&1 | FileCheck %s
 
 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 
@@ -10,15 +10,16 @@ target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
 ; for (i = 0; i < 20; ++i)
 ;   A[i*i] *= 2;
 
-; CHECK: for.body:
-; CHECK:     Report: unsafe dependent memory operations in loop
-; CHECK-NOT: Report: cannot identify array bounds
-; CHECK:     Dependences:
-; CHECK:       Unknown:
-; CHECK:           %loadA = load i16, i16* %arrayidxA, align 2 ->
-; CHECK:           store i16 %mul, i16* %arrayidxA, align 2
+; CHECK-LABEL: addrec_squared
+; CHECK-NEXT: for.body:
+; CHECK-NEXT:   Report: unsafe dependent memory operations in loop
+; CHECK-NOT:    Report: cannot identify array bounds
+; CHECK-NEXT:     Dependences:
+; CHECK-NEXT:       Unknown:
+; CHECK-NEXT:         %loadA = load i16, i16* %arrayidxA, align 2 ->
+; CHECK-NEXT:         store i16 %mul, i16* %arrayidxA, align 2
 
-define void @f(i16* %a) {
+define void @addrec_squared(i16* %a) {
 entry:
   br label %for.body
 
@@ -41,3 +42,39 @@ for.body:                                         ; preds = %for.body, %entry
 for.end:                                          ; preds = %for.body
   ret void
 }
+
+; TODO: We cannot compute the bound for %arrayidxA_ub, because the index is
+; loaded on each iteration. As %a and %b are no-alias, no memchecks are required
+; and unknown bounds should not prevent further analysis.
+define void @loaded_bound(i16* noalias %a, i16* noalias %b) {
+; CHECK-LABEL: loaded_bound
+; CHECK-NEXT:  for.body:
+; CHECK-NEXT:    Report: cannot identify array bounds
+; CHECK-NEXT:    Dependences:
+; CHECK-NEXT:    Run-time memory checks:
+
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %for.body, %entry
+  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
+
+  %iv.next = add nuw nsw i64 %iv, 1
+
+  %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %iv
+  %loadB = load i16, i16* %arrayidxB, align 2
+
+  %arrayidxA_ub = getelementptr inbounds i16, i16* %a, i16 %loadB
+  %loadA_ub = load i16, i16* %arrayidxA_ub, align 2
+
+  %mul = mul i16 %loadB, %loadA_ub
+
+  %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %iv
+  store i16 %mul, i16* %arrayidxA, align 2
+
+  %exitcond = icmp eq i64 %iv, 20
+  br i1 %exitcond, label %for.end, label %for.body
+
+for.end:                                          ; preds = %for.body
+  ret void
+}

diff  --git a/llvm/test/Analysis/LoopAccessAnalysis/uncomputable-backedge-taken-count.ll b/llvm/test/Analysis/LoopAccessAnalysis/uncomputable-backedge-taken-count.ll
new file mode 100644
index 000000000000..63e27f46bb17
--- /dev/null
+++ b/llvm/test/Analysis/LoopAccessAnalysis/uncomputable-backedge-taken-count.ll
@@ -0,0 +1,113 @@
+; RUN: opt -basic-aa -loop-accesses -analyze -enable-new-pm=0 < %s | FileCheck %s
+; RUN: opt -passes='require<aa>,require<scalar-evolution>,require<aa>,loop(print-access-info)' -aa-pipeline='basic-aa' -disable-output < %s  2>&1 | FileCheck %s
+
+target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.10.0"
+
+; TODO: Loop iteration counts are only required if we generate memory
+;       runtime checks. Missing iteration counts should not prevent
+;       analysis, if no runtime checks are required.
+
+; No memory checks are required, because base pointers do not alias and we have
+; a forward dependence for %a.
+define void @safe_forward_dependence(i16* noalias %a,
+                                     i16* noalias %b) {
+; CHECK-LABEL: safe_forward_dependence
+; CHECK:       for.body:
+; CHECK-NEXT:     Report: could not determine number of loop iterations
+;
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %for.body, %entry
+  %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
+
+  %iv.next = add nuw nsw i64 %iv, 1
+
+  %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %iv.next
+  %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2
+
+  %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %iv
+  %loadB = load i16, i16* %arrayidxB, align 2
+
+
+  %mul = mul i16 %loadB, %loadA_plus_2
+
+  %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %iv
+  store i16 %mul, i16* %arrayidxA, align 2
+
+  %exitcond = icmp eq i16 %loadB, 20
+  br i1 %exitcond, label %for.end, label %for.body
+
+for.end:                                          ; preds = %for.body
+  ret void
+}
+
+
+
+
+define void @unsafe_backwards_dependence(i16* noalias %a,
+                                         i16* noalias %b) {
+; CHECK-LABEL: unsafe_backwards_dependence
+; CHECK:       for.body:
+; CHECK-NEXT:     Report: could not determine number of loop iterations
+;
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %for.body, %entry
+  %iv = phi i64 [ 1, %entry ], [ %iv.next, %for.body ]
+
+  %idx = add nuw nsw i64 %iv, -1
+  %iv.next = add nuw nsw i64 %iv, 1
+
+  %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %idx
+  %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2
+
+  %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %iv
+  %loadB = load i16, i16* %arrayidxB, align 2
+
+
+  %mul = mul i16 %loadB, %loadA_plus_2
+
+  %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %iv
+  store i16 %mul, i16* %arrayidxA, align 2
+
+  %exitcond = icmp eq i16 %loadB, 20
+  br i1 %exitcond, label %for.end, label %for.body
+
+for.end:                                          ; preds = %for.body
+  ret void
+}
+
+
+define void @ptr_may_alias(i16* %a, i16* %b) {
+; CHECK-LABEL: ptr_may_alias
+; CHECK:       for.body:
+; CHECK-NEXT:     Report: could not determine number of loop iterations
+;
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %for.body, %entry
+  %iv = phi i64 [ 1, %entry ], [ %iv.next, %for.body ]
+
+  %idx = add nuw nsw i64 %iv, -1
+  %iv.next = add nuw nsw i64 %iv, 1
+
+  %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %iv
+  %loadA = load i16, i16* %arrayidxA, align 2
+
+  %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %iv
+  %loadB = load i16, i16* %arrayidxB, align 2
+
+  %mul = mul i16 %loadB, %loadA
+
+  store i16 %mul, i16* %arrayidxA, align 2
+
+  %exitcond = icmp eq i16 %loadB, 20
+  br i1 %exitcond, label %for.end, label %for.body
+
+for.end:                                          ; preds = %for.body
+  ret void
+}


        


More information about the llvm-branch-commits mailing list