1 ; RUN: opt -basic-aa -loop-accesses -analyze -enable-new-pm=0 < %s | FileCheck %s
2 ; 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
4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5 target triple = "x86_64-apple-macosx10.10.0"
7 ; TODO: Loop iteration counts are only required if we generate memory
8 ; runtime checks. Missing iteration counts should not prevent
9 ; analysis, if no runtime checks are required.
11 ; No memory checks are required, because base pointers do not alias and we have
12 ; a forward dependence for %a.
13 define void @safe_forward_dependence(i16* noalias %a,
15 ; CHECK-LABEL: safe_forward_dependence
17 ; CHECK-NEXT: Report: could not determine number of loop iterations
22 for.body: ; preds = %for.body, %entry
23 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
25 %iv.next = add nuw nsw i64 %iv, 1
27 %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %iv.next
28 %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2
30 %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %iv
31 %loadB = load i16, i16* %arrayidxB, align 2
34 %mul = mul i16 %loadB, %loadA_plus_2
36 %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %iv
37 store i16 %mul, i16* %arrayidxA, align 2
39 %exitcond = icmp eq i16 %loadB, 20
40 br i1 %exitcond, label %for.end, label %for.body
42 for.end: ; preds = %for.body
49 define void @unsafe_backwards_dependence(i16* noalias %a,
51 ; CHECK-LABEL: unsafe_backwards_dependence
53 ; CHECK-NEXT: Report: could not determine number of loop iterations
58 for.body: ; preds = %for.body, %entry
59 %iv = phi i64 [ 1, %entry ], [ %iv.next, %for.body ]
61 %idx = add nuw nsw i64 %iv, -1
62 %iv.next = add nuw nsw i64 %iv, 1
64 %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %idx
65 %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2
67 %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %iv
68 %loadB = load i16, i16* %arrayidxB, align 2
71 %mul = mul i16 %loadB, %loadA_plus_2
73 %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %iv
74 store i16 %mul, i16* %arrayidxA, align 2
76 %exitcond = icmp eq i16 %loadB, 20
77 br i1 %exitcond, label %for.end, label %for.body
79 for.end: ; preds = %for.body
84 define void @ptr_may_alias(i16* %a, i16* %b) {
85 ; CHECK-LABEL: ptr_may_alias
87 ; CHECK-NEXT: Report: could not determine number of loop iterations
92 for.body: ; preds = %for.body, %entry
93 %iv = phi i64 [ 1, %entry ], [ %iv.next, %for.body ]
95 %idx = add nuw nsw i64 %iv, -1
96 %iv.next = add nuw nsw i64 %iv, 1
98 %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %iv
99 %loadA = load i16, i16* %arrayidxA, align 2
101 %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %iv
102 %loadB = load i16, i16* %arrayidxB, align 2
104 %mul = mul i16 %loadB, %loadA
106 store i16 %mul, i16* %arrayidxA, align 2
108 %exitcond = icmp eq i16 %loadB, 20
109 br i1 %exitcond, label %for.end, label %for.body
111 for.end: ; preds = %for.body