blob: 069135e8525826e35b088e9cd8c9c9f017f32e26 [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
Adam Nemetb45516e2015-11-03 20:13:23 +000010; Check the loop-carried forward anti-dep between the load of A[i+1] and the
11; store of A[i];
12
Adam Nemet26da8e92015-04-14 01:12:55 +000013; CHECK: Memory dependences are safe{{$}}
Adam Nemetb45516e2015-11-03 20:13:23 +000014; CHECK-NEXT: Interesting 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
Adam Nemet26da8e92015-04-14 01:12:55 +000019
20define void @f(i16* noalias %a,
21 i16* noalias %b,
22 i16* noalias %c) {
23entry:
24 br label %for.body
25
26for.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
49for.end: ; preds = %for.body
50 ret void
51}