Revert 240130, it caused crashes (repro in PR23900).
[oota-llvm.git] / test / Analysis / LoopAccessAnalysis / resort-to-memchecks-only.ll
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 interesting 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
11 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
12 target triple = "x86_64-apple-macosx10.10.0"
13
14 ; CHECK: Memory dependences are safe with run-time checks
15 ; CHECK-NEXT: Interesting Dependences:
16 ; CHECK-NEXT: Run-time memory checks:
17 ; CHECK-NEXT: 0:
18 ; CHECK-NEXT:   %arrayidxA2 = getelementptr inbounds i16, i16* %a, i64 %idx
19 ; CHECK-NEXT:   %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %indvar
20
21 @B = common global i16* null, align 8
22 @A = common global i16* null, align 8
23 @C = common global i16* null, align 8
24
25 define void @f(i64 %offset) {
26 entry:
27   %a = load i16*, i16** @A, align 8
28   %b = load i16*, i16** @B, align 8
29   %c = load i16*, i16** @C, align 8
30   br label %for.body
31
32 for.body:                                         ; preds = %for.body, %entry
33   %indvar = phi i64 [ 0, %entry ], [ %add, %for.body ]
34
35   %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %indvar
36   %loadA = load i16, i16* %arrayidxA, align 2
37
38   %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %indvar
39   %loadB = load i16, i16* %arrayidxB, align 2
40
41   %arrayidxC = getelementptr inbounds i16, i16* %c, i64 %indvar
42   %loadC = load i16, i16* %arrayidxC, align 2
43
44   %mul = mul i16 %loadB, %loadA
45   %mul1 = mul i16 %mul, %loadC
46
47   %idx = add i64 %indvar, %offset
48   %arrayidxA2 = getelementptr inbounds i16, i16* %a, i64 %idx
49   store i16 %mul1, i16* %arrayidxA2, align 2
50
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
54
55 for.end:                                          ; preds = %for.body
56   ret void
57 }