1; RUN: opt %loadPolly -analyze -polly-scops  -polly-detect-keep-going -polly-allow-nonaffine < %s | FileCheck %s
2;
3; TODO: FIXME: Investigate why "-polly-detect-keep-going" is needed to detect
4;              this SCoP. That flag should not make a difference.
5;
6; CHECK:         Context:
7; CHECK-NEXT:    [N] -> {  : -2147483648 <= N <= 2147483647 }
8; CHECK-NEXT:    Assumed Context:
9; CHECK-NEXT:    [N] -> {  :  }
10; CHECK-NEXT:    Invalid Context:
11; CHECK-NEXT:    [N] -> {  : N >= 514 }
12;
13; CHECK:         Statements {
14; CHECK-NEXT:    	Stmt_if_end3
15; CHECK-NEXT:            Domain :=
16; CHECK-NEXT:                [N] -> { Stmt_if_end3[i0] : 0 <= i0 < N };
17; CHECK-NEXT:            Schedule :=
18; CHECK-NEXT:                [N] -> { Stmt_if_end3[i0] -> [i0] };
19; CHECK-NEXT:            ReadAccess :=	[Reduction Type: +] [Scalar: 0]
20; CHECK-NEXT:                [N] -> { Stmt_if_end3[i0] -> MemRef_A[i0] };
21; CHECK-NEXT:            MustWriteAccess :=	[Reduction Type: +] [Scalar: 0]
22; CHECK-NEXT:                [N] -> { Stmt_if_end3[i0] -> MemRef_A[i0] };
23; CHECK-NEXT:    }
24;
25;    int f();
26;    void g(int *A, int N) {
27;      for (int i = 0; i < N; i++) {
28;        if (i > 512) {
29;          int v = f();
30;        S:
31;          A[v]++;
32;        }
33;        A[i]++;
34;      }
35;    }
36;
37target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
38
39define void @g(i32* %A, i32 %N) {
40entry:
41  %tmp = sext i32 %N to i64
42  br label %for.cond
43
44for.cond:                                         ; preds = %for.inc, %entry
45  %indvars.iv = phi i64 [ %indvars.iv.next, %for.inc ], [ 0, %entry ]
46  %cmp = icmp slt i64 %indvars.iv, %tmp
47  br i1 %cmp, label %for.body, label %for.end
48
49for.body:                                         ; preds = %for.cond
50  %cmp1 = icmp sgt i64 %indvars.iv, 512
51  br i1 %cmp1, label %if.then, label %if.end3
52
53if.then:                                          ; preds = %for.body
54  %call = call i32 (...) @f()
55  br label %S
56
57S:                                                ; preds = %if.then
58  %idxprom = sext i32 %call to i64
59  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %idxprom
60  %tmp1 = load i32, i32* %arrayidx, align 4
61  %inc = add nsw i32 %tmp1, 1
62  store i32 %inc, i32* %arrayidx, align 4
63  br label %if.end3
64
65if.end3:                                          ; preds = %if.end, %for.body
66  %arrayidx5 = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
67  %tmp2 = load i32, i32* %arrayidx5, align 4
68  %inc6 = add nsw i32 %tmp2, 1
69  store i32 %inc6, i32* %arrayidx5, align 4
70  br label %for.inc
71
72for.inc:                                          ; preds = %if.end3, %if.then2
73  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
74  br label %for.cond
75
76for.end:                                          ; preds = %for.cond
77  ret void
78}
79
80declare i32 @f(...)
81