1; RUN: opt -S -structurizecfg %s -o - | FileCheck %s
2;
3; void loop(int *out, int cond_a, int cond_b) {
4;
5;   unsigned i;
6;   for (i = 0; i < cond_a; i++) {
7;     out[i] = i;
8;     if (i > cond_b) {
9;       break;
10;     }
11;     out[i + cond_a] = i;
12;   }
13; }
14
15define void @loop(i32 addrspace(1)* %out, i32 %cond_a, i32 %cond_b) nounwind uwtable {
16entry:
17  br label %for.cond
18
19for.cond:                                         ; preds = %for.inc, %entry
20  %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
21  %cmp = icmp ult i32 %i.0, %cond_a
22  br i1 %cmp, label %for.body, label %for.end
23
24; CHECK: for.body:
25for.body:                                         ; preds = %for.cond
26  %arrayidx = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 %i.0
27  store i32 %i.0, i32 addrspace(1)* %arrayidx, align 4
28  %cmp1 = icmp ugt i32 %i.0, %cond_b
29; CHECK: br i1 %{{[0-9a-zA-Z_]+}}, label %for.inc, label %[[FLOW1:[0-9a-zA-Z_]+]]
30  br i1 %cmp1, label %for.end, label %for.inc
31
32; CHECK: [[FLOW:[0-9a-zA-Z]+]]:
33; CHECK: br i1 %{{[0-9a-zA-Z_]+}}, label %for.end, label %for.cond
34
35; CHECK: for.inc:
36; CHECK: br label %[[FLOW1]]
37
38for.inc:                                          ; preds = %for.body
39  %0 = add i32 %cond_a, %i.0
40  %arrayidx3 = getelementptr inbounds i32, i32 addrspace(1)* %out, i32 %0
41  store i32 %i.0, i32 addrspace(1)* %arrayidx3, align 4
42  %inc = add i32 %i.0, 1
43  br label %for.cond
44
45; CHECK: [[FLOW1]]
46; CHECK: br label %[[FLOW]]
47
48for.end:                                          ; preds = %for.cond, %for.body
49  ret void
50}
51