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