1; RUN: opt %loadPolly -polly-stmt-granularity=bb -polly-scops -analyze < %s | FileCheck %s
2;
3; CHECK:      Context:
4; CHECK-NEXT: {  :  }
5; CHECK:      Assumed Context:
6; CHECK-NEXT: {  :  }
7; CHECK:      Invalid Context:
8; CHECK-NEXT: {  : false }
9; CHECK:      Statements {
10; CHECK-NEXT:     Stmt_for_body
11; CHECK-NEXT:         Domain :=
12; CHECK-NEXT:             { Stmt_for_body[i0] : 0 <= i0 <= 99 };
13; CHECK-NEXT:         Schedule :=
14; CHECK-NEXT:             { Stmt_for_body[i0] -> [i0] };
15; CHECK-NEXT:         ReadAccess :=    [Reduction Type: +] [Scalar: 0]
16; CHECK-NEXT:             { Stmt_for_body[i0] -> MemRef_A[i0, 0] };
17; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: +] [Scalar: 0]
18; CHECK-NEXT:             { Stmt_for_body[i0] -> MemRef_A[i0, 0] };
19; CHECK-NEXT:         ReadAccess :=    [Reduction Type: +] [Scalar: 0]
20; CHECK-NEXT:             { Stmt_for_body[i0] -> MemRef_A[1 + i0, 0] };
21; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: +] [Scalar: 0]
22; CHECK-NEXT:             { Stmt_for_body[i0] -> MemRef_A[1 + i0, 0] };
23; CHECK-NEXT: }
24;
25;    void f(int A[][2]) {
26;      int(*B)[2] = &A[0][0];
27;      int(*C)[2] = &A[1][0];
28;      for (int i = 0; i < 100; i++) {
29;        B[i][0]++;
30;        C[i][0]++;
31;      }
32;    }
33;
34; Verify that the additional offset to A by accessing it through C is taken into
35; account.
36;
37target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
38
39define void @f([2 x i32]* %A) {
40entry:
41  %arrayidx3 = getelementptr inbounds [2 x i32], [2 x i32]* %A, i64 1, i64 0
42  %tmp = bitcast i32* %arrayidx3 to [2 x i32]*
43  br label %for.cond
44
45for.cond:                                         ; preds = %for.inc, %entry
46  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
47  %exitcond = icmp ne i64 %indvars.iv, 100
48  br i1 %exitcond, label %for.body, label %for.end
49
50for.body:                                         ; preds = %for.cond
51  %arrayidx5 = getelementptr inbounds [2 x i32], [2 x i32]* %A, i64 %indvars.iv, i64 0
52  %tmp1 = load i32, i32* %arrayidx5, align 4
53  %inc = add nsw i32 %tmp1, 1
54  store i32 %inc, i32* %arrayidx5, align 4
55  %arrayidx8 = getelementptr inbounds [2 x i32], [2 x i32]* %tmp, i64 %indvars.iv, i64 0
56  %tmp2 = load i32, i32* %arrayidx8, align 4
57  %inc9 = add nsw i32 %tmp2, 1
58  store i32 %inc9, i32* %arrayidx8, align 4
59  br label %for.inc
60
61for.inc:                                          ; preds = %for.body
62  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
63  br label %for.cond
64
65for.end:                                          ; preds = %for.cond
66  ret void
67}
68