1 ; RUN: opt -loop-accesses -analyze < %s | FileCheck %s
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 interesting dependences are reported in
8 ; for (i = 0; i < n; i++)
9 ; A[i + offset] = A[i] * B[i] * C[i];
11 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
12 target triple = "x86_64-apple-macosx10.10.0"
14 ; CHECK: Memory dependences are safe with run-time checks
15 ; CHECK-NEXT: Interesting Dependences:
16 ; CHECK-NEXT: Run-time memory checks:
18 ; CHECK-NEXT: %arrayidxA2 = getelementptr inbounds i16, i16* %a, i64 %idx
19 ; CHECK-NEXT: %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %indvar
21 @B = common global i16* null, align 8
22 @A = common global i16* null, align 8
23 @C = common global i16* null, align 8
25 define void @f(i64 %offset) {
27 %a = load i16*, i16** @A, align 8
28 %b = load i16*, i16** @B, align 8
29 %c = load i16*, i16** @C, align 8
32 for.body: ; preds = %for.body, %entry
33 %indvar = phi i64 [ 0, %entry ], [ %add, %for.body ]
35 %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %indvar
36 %loadA = load i16, i16* %arrayidxA, align 2
38 %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %indvar
39 %loadB = load i16, i16* %arrayidxB, align 2
41 %arrayidxC = getelementptr inbounds i16, i16* %c, i64 %indvar
42 %loadC = load i16, i16* %arrayidxC, align 2
44 %mul = mul i16 %loadB, %loadA
45 %mul1 = mul i16 %mul, %loadC
47 %idx = add i64 %indvar, %offset
48 %arrayidxA2 = getelementptr inbounds i16, i16* %a, i64 %idx
49 store i16 %mul1, i16* %arrayidxA2, align 2
51 %add = add nuw nsw i64 %indvar, 1
52 %exitcond = icmp eq i64 %add, 20
53 br i1 %exitcond, label %for.end, label %for.body
55 for.end: ; preds = %for.body