1 ; RUN: opt -aa-pipeline=basic-aa -passes='print-access-info' -disable-output < %s 2>&1 | FileCheck %s
3 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
5 ; We shouldn't quit the analysis if we encounter a pointer without known
6 ; bounds *unless* we actually need to emit a memcheck for it. (We only
7 ; compute bounds for SCEVAddRecs so A[i*i] is deemed not having known bounds.)
9 ; for (i = 0; i < 20; ++i)
12 ; CHECK-LABEL: addrec_squared
13 ; CHECK-NEXT: for.body:
14 ; CHECK-NEXT: Report: unsafe dependent memory operations in loop
15 ; CHECK-NOT: Report: cannot identify array bounds
16 ; CHECK-NEXT: Unknown data dependence.
17 ; CHECK-NEXT: Dependences:
18 ; CHECK-NEXT: Unknown:
19 ; CHECK-NEXT: %loadA = load i16, i16* %arrayidxA, align 2 ->
20 ; CHECK-NEXT: store i16 %mul, i16* %arrayidxA, align 2
22 define void @addrec_squared(i16* %a) {
26 for.body: ; preds = %for.body, %entry
27 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
29 %access_ind = mul i64 %ind, %ind
31 %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %access_ind
32 %loadA = load i16, i16* %arrayidxA, align 2
34 %mul = mul i16 %loadA, 2
36 store i16 %mul, i16* %arrayidxA, align 2
38 %add = add nuw nsw i64 %ind, 1
39 %exitcond = icmp eq i64 %add, 20
40 br i1 %exitcond, label %for.end, label %for.body
42 for.end: ; preds = %for.body
46 ; TODO: We cannot compute the bound for %arrayidxA_ub, because the index is
47 ; loaded on each iteration. As %a and %b are no-alias, no memchecks are required
48 ; and unknown bounds should not prevent further analysis.
49 define void @loaded_bound(i16* noalias %a, i16* noalias %b) {
50 ; CHECK-LABEL: loaded_bound
51 ; CHECK-NEXT: for.body:
52 ; CHECK-NEXT: Report: cannot identify array bounds
53 ; CHECK-NEXT: Dependences:
54 ; CHECK-NEXT: Run-time memory checks:
59 for.body: ; preds = %for.body, %entry
60 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
62 %iv.next = add nuw nsw i64 %iv, 1
64 %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %iv
65 %loadB = load i16, i16* %arrayidxB, align 2
67 %arrayidxA_ub = getelementptr inbounds i16, i16* %a, i16 %loadB
68 %loadA_ub = load i16, i16* %arrayidxA_ub, align 2
70 %mul = mul i16 %loadB, %loadA_ub
72 %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %iv
73 store i16 %mul, i16* %arrayidxA, align 2
75 %exitcond = icmp eq i64 %iv, 20
76 br i1 %exitcond, label %for.end, label %for.body
78 for.end: ; preds = %for.body