• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3
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];
7
8target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
9target triple = "x86_64-apple-macosx10.10.0"
10
11; Check the loop-carried forward anti-dep between the load of A[i+1] and the
12; store of A[i];
13
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
19
20
21define void @f(i16* noalias %a,
22               i16* noalias %b,
23               i16* noalias %c) {
24entry:
25  br label %for.body
26
27for.body:                                         ; preds = %for.body, %entry
28  %ind = phi i64 [ 0, %entry ], [ %add, %for.body ]
29
30  %add = add nuw nsw i64 %ind, 1
31
32  %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %add
33  %loadA_plus_2 = load i16, i16* %arrayidxA_plus_2, align 2
34
35  %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %ind
36  %loadB = load i16, i16* %arrayidxB, align 2
37
38  %arrayidxC = getelementptr inbounds i16, i16* %c, i64 %ind
39  %loadC = load i16, i16* %arrayidxC, align 2
40
41  %mul = mul i16 %loadB, %loadA_plus_2
42  %mul1 = mul i16 %mul, %loadC
43
44  %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %ind
45  store i16 %mul1, i16* %arrayidxA, align 2
46
47  %exitcond = icmp eq i64 %add, 20
48  br i1 %exitcond, label %for.end, label %for.body
49
50for.end:                                          ; preds = %for.body
51  ret void
52}
53