• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -loop-accesses -analyze < %s | FileCheck %s
2; RUN: opt -passes='require<scalar-evolution>,require<aa>,loop(print-access-info)' -disable-output  < %s 2>&1 | FileCheck %s
3
4; Analyze this loop:
5;   for (i = 0; i < n; i++)
6;    A[i + 1] = A[i] * 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: Report: unsafe dependent memory operations in loop
12; CHECK-NEXT: Dependences:
13; CHECK-NEXT:   Backward:
14; CHECK-NEXT:     %loadA = load i16, i16* %arrayidxA, align 2 ->
15; CHECK-NEXT:     store i16 %mul1, i16* %arrayidxA_plus_2, align 2
16; CHECK: Run-time memory checks:
17; CHECK-NEXT: 0:
18; CHECK-NEXT: Comparing group
19; CHECK-NEXT:   %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %storemerge3
20; CHECK-NEXT:   %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %add
21; CHECK-NEXT: Against group
22; CHECK-NEXT:   %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %storemerge3
23; CHECK-NEXT: 1:
24; CHECK-NEXT: Comparing group
25; CHECK-NEXT:   %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %storemerge3
26; CHECK-NEXT:   %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %add
27; CHECK-NEXT: Against group
28; CHECK-NEXT:   %arrayidxC = getelementptr inbounds i16, i16* %c, i64 %storemerge3
29
30@B = common global i16* null, align 8
31@A = common global i16* null, align 8
32@C = common global i16* null, align 8
33
34define void @f() {
35entry:
36  %a = load i16*, i16** @A, align 8
37  %b = load i16*, i16** @B, align 8
38  %c = load i16*, i16** @C, align 8
39  br label %for.body
40
41for.body:                                         ; preds = %for.body, %entry
42  %storemerge3 = phi i64 [ 0, %entry ], [ %add, %for.body ]
43
44  %arrayidxA = getelementptr inbounds i16, i16* %a, i64 %storemerge3
45  %loadA = load i16, i16* %arrayidxA, align 2
46
47  %arrayidxB = getelementptr inbounds i16, i16* %b, i64 %storemerge3
48  %loadB = load i16, i16* %arrayidxB, align 2
49
50  %arrayidxC = getelementptr inbounds i16, i16* %c, i64 %storemerge3
51  %loadC = load i16, i16* %arrayidxC, align 2
52
53  %mul = mul i16 %loadB, %loadA
54  %mul1 = mul i16 %mul, %loadC
55
56  %add = add nuw nsw i64 %storemerge3, 1
57  %arrayidxA_plus_2 = getelementptr inbounds i16, i16* %a, i64 %add
58  store i16 %mul1, i16* %arrayidxA_plus_2, align 2
59
60  %exitcond = icmp eq i64 %add, 20
61  br i1 %exitcond, label %for.end, label %for.body
62
63for.end:                                          ; preds = %for.body
64  ret void
65}
66