Taints the non-acquire RMW's store address with the load part
[oota-llvm.git] / test / Analysis / LoopAccessAnalysis / safe-no-checks.ll
1 ; RUN: opt -basicaa -loop-accesses -analyze < %s | FileCheck %s
2
3 ; If the arrays don't alias this loop is safe with no memchecks:
4 ;   for (i = 0; i < n; i++)
5 ;    A[i] = A[i+1] * B[i] * C[i];
6
7 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
8 target triple = "x86_64-apple-macosx10.10.0"
9
10 ; Check the loop-carried forward anti-dep between the load of A[i+1] and the
11 ; store of A[i];
12
13 ; CHECK: Memory dependences are safe{{$}}
14 ; CHECK-NEXT: Dependences:
15 ; CHECK-NEXT:   Forward:
16 ; CHECK-NEXT:     %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2 ->
17 ; CHECK-NEXT:     store i16 %mul1, i16* %arrayidxA, align 2
18
19
20 define void @f(i16* noalias %a,
21                i16* noalias %b,
22                i16* noalias %c) {
23 entry:
24   br label %for.body
25
26 for.body:                                         ; preds = %for.body, %entry
27   %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
28
29   %add = add nuw nsw i64 %ind, 1
30
31   %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %add
32   %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2
33
34   %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %ind
35   %loadB = load i16, i16* %arrayidxB, align 2
36
37   %arrayidxC = getelementptr inbounds i16, i16* %c, i64 %ind
38   %loadC = load i16, i16* %arrayidxC, align 2
39
40   %mul = mul i16 %loadB, %loadA_plus_2
41   %mul1 = mul i16 %mul, %loadC
42
43   %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %ind
44   store i16 %mul1, i16* %arrayidxA, align 2
45
46   %exitcond = icmp eq i64 %add, 20
47   br i1 %exitcond, label %for.end, label %for.body
48
49 for.end:                                          ; preds = %for.body
50   ret void
51 }