1; RUN: opt -loop-unroll -verify-loop-lcssa -S < %s | FileCheck %s
2
3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
4target triple = "x86_64-unknown-linux-gnu"
5
6@b = external local_unnamed_addr global i32, align 4
7
8; CHECK-LABEL: @main
9; CHECK: exit.loopexit:
10; CHECK: {{.*}} = phi i32 [ %d.0, %h3 ]
11; CHECK: br label %exit
12; CHECK: exit.loopexit1:
13; CHECK: {{.*}} = phi i32 [ %d.0, %h3.1 ]
14; CHECK: br label %exit
15
16define void @main() local_unnamed_addr #0 {
17ph1:
18  br label %h1
19
20h1:
21  %d.0 = phi i32 [ %1, %latch1 ], [ undef, %ph1 ]
22  br label %ph2
23
24ph2:
25  br label %h2
26
27h2:
28  %0 = phi i32 [ 0, %ph2 ], [ %inc, %latch2 ]
29  br label %h3
30
31h3:
32  br i1 undef, label %latch3, label %exit
33
34latch3:
35  br i1 false, label %exit3, label %h3
36
37exit3:
38  br label %latch2
39
40latch2:
41  %inc = add nuw nsw i32 %0, 1
42  %cmp = icmp slt i32 %inc, 2
43  br i1 %cmp, label %h2, label %exit2
44
45exit2:
46  br i1 undef, label %latch1, label %ph2
47
48latch1:                 ; preds = %exit2
49  %1 = load i32, i32* @b, align 4
50  br label %h1
51
52exit:
53  %d.0.lcssa = phi i32 [ %d.0, %h3 ]
54  ret void
55}
56