1 ; RUN: opt -basicaa -loop-accesses -analyze < %s | FileCheck %s
2 ; RUN: opt -passes='require<aa>,require<scalar-evolution>,require<aa>,loop(print-access-info)' -aa-pipeline='basic-aa' -disable-output < %s 2>&1 | FileCheck %s
4 ; If the arrays don't alias this loop is safe with no memchecks:
5 ; for (i = 0; i < n; i++)
6 ; A[i] = A[i+1] * B[i] * C[i];
8 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
9 target triple = "x86_64-apple-macosx10.10.0"
11 ; Check the loop-carried forward anti-dep between the load of A[i+1] and the
14 ; CHECK: Memory dependences are safe{{$}}
15 ; CHECK-NEXT: Dependences:
16 ; CHECK-NEXT: Forward:
17 ; CHECK-NEXT: %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2 ->
18 ; CHECK-NEXT: store i16 %mul1, i16* %arrayidxA, align 2
21 define void @f(i16* noalias %a,
27 for.body: ; preds = %for.body, %entry
28 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
30 %add = add nuw nsw i64 %ind, 1
32 %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %add
33 %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2
35 %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %ind
36 %loadB = load i16, i16* %arrayidxB, align 2
38 %arrayidxC = getelementptr inbounds i16, i16* %c, i64 %ind
39 %loadC = load i16, i16* %arrayidxC, align 2
41 %mul = mul i16 %loadB, %loadA_plus_2
42 %mul1 = mul i16 %mul, %loadC
44 %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %ind
45 store i16 %mul1, i16* %arrayidxA, align 2
47 %exitcond = icmp eq i64 %add, 20
48 br i1 %exitcond, label %for.end, label %for.body
50 for.end: ; preds = %for.body