1; RUN: opt %loadPolly -polly-scops -analyze < %s | FileCheck %s
2;
3; Test comes from a bug (15771) or better a feature request. It was not allowed
4; in Polly in the old domain generation as ScalarEvolution cannot figure out the
5; loop bounds. However, the new domain generation will detect the SCoP.
6
7; CHECK:      Context:
8; CHECK-NEXT: [n] -> {  : -2147483648 <= n <= 2147483647 }
9;
10; CHECK:      p0: %n
11;
12; CHECK:      Statements {
13; CHECK-NEXT:     Stmt_for_next
14; CHECK-NEXT:         Domain :=
15; CHECK-NEXT:             [n] -> { Stmt_for_next[i0] : i0 >= 0 and 2i0 <= -3 + n };
16; CHECK-NEXT:         Schedule :=
17; CHECK-NEXT:             [n] -> { Stmt_for_next[i0] -> [i0] };
18; CHECK-NEXT:         ReadAccess :=    [Reduction Type: +] [Scalar: 0]
19; CHECK-NEXT:             [n] -> { Stmt_for_next[i0] -> MemRef_A[i0] };
20; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: +] [Scalar: 0]
21; CHECK-NEXT:             [n] -> { Stmt_for_next[i0] -> MemRef_A[i0] };
22; CHECK-NEXT: }
23
24@A = common global [100 x i32] zeroinitializer, align 16
25
26define void @foo(i32 %n) #0 {
27entry:
28  br label %entry.split
29
30entry.split:                                      ; preds = %entry
31  %cmp2 = icmp sgt i32 %n, 0
32  br i1 %cmp2, label %for.body.lr.ph, label %for.end
33
34for.body.lr.ph:                                   ; preds = %entry.split
35  br label %for.body
36
37for.body:                                         ; preds = %for.body.lr.ph, %for.body
38  %indvar = phi i64 [ 0, %for.body.lr.ph ], [ %indvar.next, %for.next ]
39  %arrayidx = getelementptr [100 x i32], [100 x i32]* @A, i64 0, i64 %indvar
40  %0 = mul i64 %indvar, 2
41  %1 = add i64 %0, 2
42  %add1 = trunc i64 %1 to i32
43  %cmp = icmp slt i32 %add1, %n
44  %indvar.next = add i64 %indvar, 1
45  br i1 %cmp, label %for.next, label %for.cond.for.end_crit_edge
46
47for.next:
48  %2 = load i32, i32* %arrayidx, align 4
49  %add = add nsw i32 %2, 1
50  store i32 %add, i32* %arrayidx, align 4
51  br label %for.body
52
53for.cond.for.end_crit_edge:                       ; preds = %for.body
54  br label %for.end
55
56for.end:                                          ; preds = %for.cond.for.end_crit_edge, %entry.split
57  ret void
58}
59