1; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
2; RUN: opt %loadPolly -polly-function-scops -analyze < %s | FileCheck %s
3
4; void f(long a[][128], long N, long M) {
5;   long i, j;
6;   for (j = 0; j < (4*N + 7*M +3); ++j)
7;     for (i = 0; i < (5*N + 2); ++i)
8;       a[j][i] = 0
9;   }
10
11target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128"
12
13define void @f([128 x i64]* nocapture %a, i64 %N, i64 %M) nounwind {
14entry:
15  %0 = shl i64 %N, 2                              ; <i64> [#uses=2]
16  %1 = mul i64 %M, 7                              ; <i64> [#uses=2]
17  %2 = or i64 %0, 3                               ; <i64> [#uses=1]
18  %3 = add nsw i64 %2, %1                         ; <i64> [#uses=1]
19  %4 = icmp sgt i64 %3, 0                         ; <i1> [#uses=1]
20  br i1 %4, label %bb.nph8, label %return
21
22bb1:                                              ; preds = %bb2.preheader, %bb1
23  %i.06 = phi i64 [ 0, %bb2.preheader ], [ %5, %bb1 ] ; <i64> [#uses=2]
24  %scevgep = getelementptr [128 x i64], [128 x i64]* %a, i64 %i.06, i64 %10 ; <i64*> [#uses=1]
25  store i64 0, i64* %scevgep, align 8
26  %5 = add nsw i64 %i.06, 1                       ; <i64> [#uses=2]
27  %exitcond = icmp eq i64 %5, %8                  ; <i1> [#uses=1]
28  br i1 %exitcond, label %bb3, label %bb1
29
30bb3:                                              ; preds = %bb1
31  %6 = add i64 %10, 1                             ; <i64> [#uses=2]
32  %exitcond14 = icmp eq i64 %6, %tmp13            ; <i1> [#uses=1]
33  br i1 %exitcond14, label %return, label %bb2.preheader
34
35bb.nph8:                                          ; preds = %entry
36  %7 = mul i64 %N, 5                              ; <i64> [#uses=1]
37  %8 = add nsw i64 %7, 2                          ; <i64> [#uses=2]
38  %9 = icmp sgt i64 %8, 0                         ; <i1> [#uses=1]
39  br i1 %9, label %bb.nph8.split, label %return
40
41bb.nph8.split:                                    ; preds = %bb.nph8
42  %tmp12 = add i64 %1, %0                         ; <i64> [#uses=1]
43  %tmp13 = add i64 %tmp12, 3                      ; <i64> [#uses=1]
44  br label %bb2.preheader
45
46bb2.preheader:                                    ; preds = %bb.nph8.split, %bb3
47  %10 = phi i64 [ 0, %bb.nph8.split ], [ %6, %bb3 ] ; <i64> [#uses=2]
48  br label %bb1
49
50return:                                           ; preds = %bb.nph8, %bb3, %entry
51  ret void
52}
53
54
55; CHECK:      p0: %N
56; CHECK-NEXT: p1: %M
57;
58; CHECK:      Statements {
59; CHECK-NEXT:     Stmt_bb1
60; CHECK-NEXT:         Domain :=
61; CHECK-NEXT:             [N, M] -> { Stmt_bb1[i0, i1] : 0 <= i0 <= 2 + 4N + 7M and 0 <= i1 <= 1 + 5N };
62; CHECK-NEXT:         Schedule :=
63; CHECK-NEXT:             [N, M] -> { Stmt_bb1[i0, i1] -> [i0, i1] };
64; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
65; CHECK-NEXT:             [N, M] -> { Stmt_bb1[i0, i1] -> MemRef_a[i1, i0] };
66; CHECK-NEXT: }
67