1; RUN: opt -passes='print<access-info>' -aa-pipeline='basic-aa' -disable-output < %s 2>&1 | FileCheck %s 2 3target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 4target triple = "x86_64-apple-macosx10.10.0" 5 6; TODO: Loop iteration counts are only required if we generate memory 7; runtime checks. Missing iteration counts should not prevent 8; analysis, if no runtime checks are required. 9 10; No memory checks are required, because base pointers do not alias and we have 11; a forward dependence for %a. 12define void @safe_forward_dependence(ptr noalias %a, 13 ptr noalias %b) { 14; CHECK-LABEL: safe_forward_dependence 15; CHECK: for.body: 16; CHECK-NEXT: Report: could not determine number of loop iterations 17; 18entry: 19 br label %for.body 20 21for.body: ; preds = %for.body, %entry 22 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ] 23 24 %iv.next = add nuw nsw i64 %iv, 1 25 26 %arrayidxA_plus_2 = getelementptr inbounds i16, ptr %a, i64 %iv.next 27 %loadA_plus_2 = load i16, ptr %arrayidxA_plus_2, align 2 28 29 %arrayidxB = getelementptr inbounds i16, ptr %b, i64 %iv 30 %loadB = load i16, ptr %arrayidxB, align 2 31 32 33 %mul = mul i16 %loadB, %loadA_plus_2 34 35 %arrayidxA = getelementptr inbounds i16, ptr %a, i64 %iv 36 store i16 %mul, ptr %arrayidxA, align 2 37 38 %exitcond = icmp eq i16 %loadB, 20 39 br i1 %exitcond, label %for.end, label %for.body 40 41for.end: ; preds = %for.body 42 ret void 43} 44 45 46 47 48define void @unsafe_backwards_dependence(ptr noalias %a, 49 ptr noalias %b) { 50; CHECK-LABEL: unsafe_backwards_dependence 51; CHECK: for.body: 52; CHECK-NEXT: Report: could not determine number of loop iterations 53; 54entry: 55 br label %for.body 56 57for.body: ; preds = %for.body, %entry 58 %iv = phi i64 [ 1, %entry ], [ %iv.next, %for.body ] 59 60 %idx = add nuw nsw i64 %iv, -1 61 %iv.next = add nuw nsw i64 %iv, 1 62 63 %arrayidxA_plus_2 = getelementptr inbounds i16, ptr %a, i64 %idx 64 %loadA_plus_2 = load i16, ptr %arrayidxA_plus_2, align 2 65 66 %arrayidxB = getelementptr inbounds i16, ptr %b, i64 %iv 67 %loadB = load i16, ptr %arrayidxB, align 2 68 69 70 %mul = mul i16 %loadB, %loadA_plus_2 71 72 %arrayidxA = getelementptr inbounds i16, ptr %a, i64 %iv 73 store i16 %mul, ptr %arrayidxA, align 2 74 75 %exitcond = icmp eq i16 %loadB, 20 76 br i1 %exitcond, label %for.end, label %for.body 77 78for.end: ; preds = %for.body 79 ret void 80} 81 82 83define void @ptr_may_alias(ptr %a, ptr %b) { 84; CHECK-LABEL: ptr_may_alias 85; CHECK: for.body: 86; CHECK-NEXT: Report: could not determine number of loop iterations 87; 88entry: 89 br label %for.body 90 91for.body: ; preds = %for.body, %entry 92 %iv = phi i64 [ 1, %entry ], [ %iv.next, %for.body ] 93 94 %idx = add nuw nsw i64 %iv, -1 95 %iv.next = add nuw nsw i64 %iv, 1 96 97 %arrayidxA = getelementptr inbounds i16, ptr %a, i64 %iv 98 %loadA = load i16, ptr %arrayidxA, align 2 99 100 %arrayidxB = getelementptr inbounds i16, ptr %b, i64 %iv 101 %loadB = load i16, ptr %arrayidxB, align 2 102 103 %mul = mul i16 %loadB, %loadA 104 105 store i16 %mul, ptr %arrayidxA, align 2 106 107 %exitcond = icmp eq i16 %loadB, 20 108 br i1 %exitcond, label %for.end, label %for.body 109 110for.end: ; preds = %for.body 111 ret void 112} 113