1; RUN: opt %loadPolly -basic-aa -polly-stmt-granularity=bb -polly-scops -analyze < %s | FileCheck %s
2
3target 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-n8:16:32:64"
4
5;long f(long a[], long n) {
6;  long i, k;
7;  k = 1;
8;  for (i = 1; i < n; ++i) {
9;   a[i] = k * a[i - 1];
10;   k = a[i + 3] + a[2 * i];
11;  }
12;  return 0;
13;}
14
15define i64 @f(i64* nocapture %a, i64 %n) nounwind {
16entry:
17  %0 = icmp sgt i64 %n, 1                         ; <i1> [#uses=1]
18  br i1 %0, label %bb.nph, label %bb2
19
20bb.nph:                                           ; preds = %entry
21  %tmp = add i64 %n, -1                           ; <i64> [#uses=1]
22  %.pre = load i64, i64* %a, align 8                   ; <i64> [#uses=1]
23  br label %bb
24
25bb:                                               ; preds = %bb, %bb.nph
26  %tmp1 = phi i64 [ %.pre, %bb.nph ], [ %tmp2, %bb ]    ; <i64> [#uses=1]
27  %indvar = phi i64 [ 0, %bb.nph ], [ %tmp6, %bb ] ; <i64> [#uses=3]
28  %k.05 = phi i64 [ 1, %bb.nph ], [ %tmp5, %bb ]     ; <i64> [#uses=1]
29  %tmp6 = add i64 %indvar, 1                      ; <i64> [#uses=3]
30  %scevgep = getelementptr i64, i64* %a, i64 %tmp6     ; <i64*> [#uses=1]
31  %tmp2 = mul nsw i64 %tmp1, %k.05                      ; <i64> [#uses=2]
32  store i64 %tmp2, i64* %scevgep, align 8
33  %tmp7 = shl i64 %indvar, 1                      ; <i64> [#uses=1]
34  %tmp11 = add i64 %indvar, 4                     ; <i64> [#uses=1]
35  %tmp8 = add i64 %tmp7, 2                        ; <i64> [#uses=1]
36  %scevgep12 = getelementptr i64, i64* %a, i64 %tmp11  ; <i64*> [#uses=1]
37  %scevgep9 = getelementptr i64, i64* %a, i64 %tmp8    ; <i64*> [#uses=1]
38  %tmp3 = load i64, i64* %scevgep9, align 8               ; <i64> [#uses=1]
39  %tmp4 = load i64, i64* %scevgep12, align 8              ; <i64> [#uses=1]
40  %tmp5 = add nsw i64 %tmp3, %tmp4                         ; <i64> [#uses=1]
41  %exitcond = icmp eq i64 %tmp6, %tmp             ; <i1> [#uses=1]
42  br i1 %exitcond, label %bb2, label %bb
43
44bb2:                                              ; preds = %bb, %entry
45  ret i64 0
46}
47
48
49; CHECK:      Statements {
50; CHECK-NEXT:     Stmt_bb
51; CHECK-NEXT:         Domain :=
52; CHECK-NEXT:             [n] -> { Stmt_bb[i0] : 0 <= i0 <= -2 + n };
53; CHECK-NEXT:         Schedule :=
54; CHECK-NEXT:             [n] -> { Stmt_bb[i0] -> [i0] };
55; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 1]
56; CHECK-NEXT:             [n] -> { Stmt_bb[i0] -> MemRef_tmp1__phi[] };
57; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 1]
58; CHECK-NEXT:             [n] -> { Stmt_bb[i0] -> MemRef_tmp1__phi[] };
59; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 1]
60; CHECK-NEXT:             [n] -> { Stmt_bb[i0] -> MemRef_k_05__phi[] };
61; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 1]
62; CHECK-NEXT:             [n] -> { Stmt_bb[i0] -> MemRef_k_05__phi[] };
63; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
64; CHECK-NEXT:             [n] -> { Stmt_bb[i0] -> MemRef_a[1 + i0] };
65; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
66; CHECK-NEXT:             [n] -> { Stmt_bb[i0] -> MemRef_a[2 + 2i0] };
67; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
68; CHECK-NEXT:             [n] -> { Stmt_bb[i0] -> MemRef_a[4 + i0] };
69; CHECK-NEXT: }
70