1; RUN: opt -loop-accesses -analyze < %s | FileCheck %s 2 3; We give up analyzing the dependences in this loop due to non-constant 4; distance between A[i+offset] and A[i] and add memchecks to prove 5; independence. Make sure that no dependences are reported in 6; this case. 7; 8; for (i = 0; i < n; i++) 9; A[i + offset] = A[i] * B[i] * C[i]; 10 11target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 12target triple = "x86_64-apple-macosx10.10.0" 13 14; CHECK: Memory dependences are safe with run-time checks 15; CHECK-NEXT: Dependences: 16; CHECK-NEXT: Run-time memory checks: 17; CHECK-NEXT: 0: 18; CHECK-NEXT: Comparing group 19; CHECK-NEXT: %arrayidxA2 = getelementptr inbounds i16, i16* %a, i64 %idx 20; CHECK-NEXT: Against group 21; CHECK-NEXT: %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %indvar 22 23@B = common global i16* null, align 8 24@A = common global i16* null, align 8 25@C = common global i16* null, align 8 26 27define void @f(i64 %offset) { 28entry: 29 %a = load i16*, i16** @A, align 8 30 %b = load i16*, i16** @B, align 8 31 %c = load i16*, i16** @C, align 8 32 br label %for.body 33 34for.body: ; preds = %for.body, %entry 35 %indvar = phi i64 [ 0, %entry ], [ %add, %for.body ] 36 37 %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %indvar 38 %loadA = load i16, i16* %arrayidxA, align 2 39 40 %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %indvar 41 %loadB = load i16, i16* %arrayidxB, align 2 42 43 %arrayidxC = getelementptr inbounds i16, i16* %c, i64 %indvar 44 %loadC = load i16, i16* %arrayidxC, align 2 45 46 %mul = mul i16 %loadB, %loadA 47 %mul1 = mul i16 %mul, %loadC 48 49 %idx = add i64 %indvar, %offset 50 %arrayidxA2 = getelementptr inbounds i16, i16* %a, i64 %idx 51 store i16 %mul1, i16* %arrayidxA2, align 2 52 53 %add = add nuw nsw i64 %indvar, 1 54 %exitcond = icmp eq i64 %add, 20 55 br i1 %exitcond, label %for.end, label %for.body 56 57for.end: ; preds = %for.body 58 ret void 59} 60