1; RUN: opt %loadPolly -polly-allow-nonaffine -polly-scops -analyze < %s \
2; RUN:     -polly-use-llvm-names=true | FileCheck %s
3;
4; RUN: opt %loadPolly -polly-allow-nonaffine -polly-scops -analyze < %s \
5; RUN:     -polly-use-llvm-names=false | FileCheck %s -check-prefix=UNNAMED
6;
7;    void f(int *A, int b) {
8;      int x;
9;      for (int i = 0; i < 1024; i++) {
10;        if (b > i)
11;          x = 0;
12;        else if (b < 2 * i)
13;          x = 3;
14;        else
15;          x = b;
16;
17;        if (A[x])
18;          A[x] = 0;
19;      }
20;    }
21;
22; CHECK:      Statements {
23; CHECK-NEXT:     Stmt_bb3
24; CHECK-NEXT:         Domain :=
25; CHECK-NEXT:             [b] -> { Stmt_bb3[i0] : 0 <= i0 <= 1023 and i0 < b };
26; CHECK-NEXT:         Schedule :=
27; CHECK-NEXT:             [b] -> { Stmt_bb3[i0] -> [i0, 2] };
28; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 1]
29; CHECK-NEXT:             [b] -> { Stmt_bb3[i0] -> MemRef_x_1__phi[] };
30; CHECK-NEXT:     Stmt_bb7
31; CHECK-NEXT:         Domain :=
32; CHECK-NEXT:             [b] -> { Stmt_bb7[i0] : i0 >= b and 0 <= i0 <= 1023 and 2i0 > b };
33; CHECK-NEXT:         Schedule :=
34; CHECK-NEXT:             [b] -> { Stmt_bb7[i0] -> [i0, 1] };
35; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 1]
36; CHECK-NEXT:             [b] -> { Stmt_bb7[i0] -> MemRef_x_1__phi[] };
37; CHECK-NEXT:     Stmt_bb8
38; CHECK-NEXT:         Domain :=
39; CHECK-NEXT:             [b] -> { Stmt_bb8[0] : b = 0 };
40; CHECK-NEXT:         Schedule :=
41; CHECK-NEXT:             [b] -> { Stmt_bb8[i0] -> [0, 0] };
42; CHECK-NEXT:         MustWriteAccess :=    [Reduction Type: NONE] [Scalar: 1]
43; CHECK-NEXT:             [b] -> { Stmt_bb8[i0] -> MemRef_x_1__phi[] };
44; CHECK-NEXT:     Stmt_bb10__TO__bb18
45; CHECK-NEXT:         Domain :=
46; CHECK-NEXT:             [b] -> { Stmt_bb10__TO__bb18[i0] : 0 <= i0 <= 1023 };
47; CHECK-NEXT:         Schedule :=
48; CHECK-NEXT:             [b] -> { Stmt_bb10__TO__bb18[i0] -> [i0, 3] }
49; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 1]
50; CHECK-NEXT:             [b] -> { Stmt_bb10__TO__bb18[i0] -> MemRef_x_1__phi[] };
51; CHECK-NEXT:         ReadAccess :=    [Reduction Type: NONE] [Scalar: 0]
52; CHECK-NEXT:             [b] -> { Stmt_bb10__TO__bb18[i0] -> MemRef_A[o0] };
53; CHECK-NEXT:         MayWriteAccess :=    [Reduction Type: NONE] [Scalar: 0]
54; CHECK-NEXT:             [b] -> { Stmt_bb10__TO__bb18[i0] -> MemRef_A[o0] };
55; CHECK-NEXT: }
56
57; UNNAMED:          Arrays {
58; UNNAMED-NEXT:         i32 MemRef0__phi; // Element size 4
59; UNNAMED-NEXT:         i32 MemRef1[*]; // Element size 4
60; UNNAMED-NEXT:     }
61
62; UNNAMED:          Statements {
63; UNNAMED-NEXT:     	Stmt2
64; UNNAMED-NEXT:             Domain :=
65; UNNAMED-NEXT:                 [p_0] -> { Stmt2[i0] : 0 <= i0 <= 1023 and i0 < p_0 };
66; UNNAMED-NEXT:             Schedule :=
67; UNNAMED-NEXT:                 [p_0] -> { Stmt2[i0] -> [i0, 2] };
68; UNNAMED-NEXT:             MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 1]
69; UNNAMED-NEXT:                 [p_0] -> { Stmt2[i0] -> MemRef0__phi[] };
70; UNNAMED-NEXT:     	Stmt4
71; UNNAMED-NEXT:             Domain :=
72; UNNAMED-NEXT:                 [p_0] -> { Stmt4[i0] : i0 >= p_0 and 0 <= i0 <= 1023 and 2i0 > p_0 };
73; UNNAMED-NEXT:             Schedule :=
74; UNNAMED-NEXT:                 [p_0] -> { Stmt4[i0] -> [i0, 1] };
75; UNNAMED-NEXT:             MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 1]
76; UNNAMED-NEXT:                 [p_0] -> { Stmt4[i0] -> MemRef0__phi[] };
77; UNNAMED-NEXT:     	Stmt5
78; UNNAMED-NEXT:             Domain :=
79; UNNAMED-NEXT:                 [p_0] -> { Stmt5[0] : p_0 = 0 };
80; UNNAMED-NEXT:             Schedule :=
81; UNNAMED-NEXT:                 [p_0] -> { Stmt5[i0] -> [0, 0] };
82; UNNAMED-NEXT:             MustWriteAccess :=	[Reduction Type: NONE] [Scalar: 1]
83; UNNAMED-NEXT:                 [p_0] -> { Stmt5[i0] -> MemRef0__phi[] };
84; UNNAMED-NEXT:     	Stmt6
85; UNNAMED-NEXT:             Domain :=
86; UNNAMED-NEXT:                 [p_0] -> { Stmt6[i0] : 0 <= i0 <= 1023 };
87; UNNAMED-NEXT:             Schedule :=
88; UNNAMED-NEXT:                 [p_0] -> { Stmt6[i0] -> [i0, 3] };
89; UNNAMED-NEXT:             ReadAccess :=	[Reduction Type: NONE] [Scalar: 1]
90; UNNAMED-NEXT:                 [p_0] -> { Stmt6[i0] -> MemRef0__phi[] };
91; UNNAMED-NEXT:             ReadAccess :=	[Reduction Type: NONE] [Scalar: 0]
92; UNNAMED-NEXT:                 [p_0] -> { Stmt6[i0] -> MemRef1[o0] };
93; UNNAMED-NEXT:             MayWriteAccess :=	[Reduction Type: NONE] [Scalar: 0]
94; UNNAMED-NEXT:                 [p_0] -> { Stmt6[i0] -> MemRef1[o0] };
95; UNNAMED-NEXT:     }
96
97
98target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
99
100define void @f(i32* %A, i32 %b) {
101bb:
102  br label %bb1
103
104bb1:                                              ; preds = %bb19, %bb
105  %i.0 = phi i32 [ 0, %bb ], [ %tmp20, %bb19 ]
106  %exitcond = icmp ne i32 %i.0, 1024
107  br i1 %exitcond, label %bb2, label %bb21
108
109bb2:                                              ; preds = %bb1
110  %tmp = icmp slt i32 %i.0, %b
111  br i1 %tmp, label %bb3, label %bb4
112
113bb3:                                              ; preds = %bb2
114  br label %bb10
115
116bb4:                                              ; preds = %bb2
117  %tmp5 = mul nsw i32 %i.0, 2
118  %tmp6 = icmp sgt i32 %tmp5, %b
119  br i1 %tmp6, label %bb7, label %bb8
120
121bb7:                                              ; preds = %bb4
122  br label %bb10
123
124bb8:                                              ; preds = %bb4
125  br label %bb10
126
127bb10:                                             ; preds = %bb9, %bb3
128  %x.1 = phi i32 [ 0, %bb3 ], [ 3, %bb7 ], [ %b, %bb8 ]
129  %tmp11 = sext i32 %x.1 to i64
130  %tmp12 = getelementptr inbounds i32, i32* %A, i64 %tmp11
131  %tmp13 = load i32,  i32* %tmp12, align 4
132  %tmp14 = icmp eq i32 %tmp13, 0
133  br i1 %tmp14, label %bb18, label %bb15
134
135bb15:                                             ; preds = %bb10
136  %tmp16 = sext i32 %x.1 to i64
137  %tmp17 = getelementptr inbounds i32, i32* %A, i64 %tmp16
138  store i32 0, i32* %tmp17, align 4
139  br label %bb18
140
141bb18:                                             ; preds = %bb10, %bb15
142  br label %bb19
143
144bb19:                                             ; preds = %bb18
145  %tmp20 = add nuw nsw i32 %i.0, 1
146  br label %bb1
147
148bb21:                                             ; preds = %bb1
149  ret void
150}
151