blob: fa70c024a9c577ee5992eff080f84761125794d8 [file] [log] [blame]
Adam Nemet26da8e92015-04-14 01:12:55 +00001; 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
7target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
8target triple = "x86_64-apple-macosx10.10.0"
9
10; CHECK: Memory dependences are safe{{$}}
11
12define void @f(i16* noalias %a,
13 i16* noalias %b,
14 i16* noalias %c) {
15entry:
16 br label %for.body
17
18for.body: ; preds = %for.body, %entry
19 %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
20
21 %add = add nuw nsw i64 %ind, 1
22
23 %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %add
24 %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2
25
26 %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %ind
27 %loadB = load i16, i16* %arrayidxB, align 2
28
29 %arrayidxC = getelementptr inbounds i16, i16* %c, i64 %ind
30 %loadC = load i16, i16* %arrayidxC, align 2
31
32 %mul = mul i16 %loadB, %loadA_plus_2
33 %mul1 = mul i16 %mul, %loadC
34
35 %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %ind
36 store i16 %mul1, i16* %arrayidxA, align 2
37
38 %exitcond = icmp eq i64 %add, 20
39 br i1 %exitcond, label %for.end, label %for.body
40
41for.end: ; preds = %for.body
42 ret void
43}