1 ; RUN: opt -passes='print<loopnest>' %s 2>&1 | FileCheck %s
2 @global = external dso_local global [1000 x [1000 x i32]], align 16
4 ; CHECK: IsPerfect=true, Depth=1, OutermostLoop: inner.header, Loops: ( inner.header )
5 ; CHECK-NEXT: IsPerfect=true, Depth=2, OutermostLoop: outer.header, Loops: ( outer.header inner.header )
7 define void @foo1(i1 %cmp) {
9 br i1 %cmp, label %bb1, label %bb1
11 bb1: ; preds = %entry, %entry
12 br i1 %cmp, label %outer.header.preheader, label %outer.header.preheader
14 outer.header.preheader: ; preds = %bb1, %bb1
15 br label %outer.header
17 outer.header: ; preds = %outer.header.preheader, %outer.latch
18 %outer.iv = phi i64 [ %outer.iv.next, %outer.latch ], [ 0, %outer.header.preheader ]
19 br i1 %cmp, label %inner.header.preheader, label %inner.header.preheader
21 inner.header.preheader: ; preds = %outer.header, %outer.header
22 br label %inner.header
24 inner.header: ; preds = %inner.header.preheader, %inner.header
25 %inner.iv = phi i64 [ %inner.iv.next, %inner.header ], [ 5, %inner.header.preheader ]
26 %ptr = getelementptr inbounds [1000 x [1000 x i32]], ptr @global, i64 0, i64 %inner.iv, i64 %outer.iv
27 %lv = load i32, ptr %ptr, align 4
29 store i32 %v, ptr %ptr, align 4
30 %inner.iv.next = add nsw i64 %inner.iv, 1
31 %cond1 = icmp eq i64 %inner.iv.next, 1000
32 br i1 %cond1, label %outer.latch, label %inner.header
34 outer.latch: ; preds = %inner.header
35 %outer.iv.next = add nuw nsw i64 %outer.iv, 1
36 %cond2 = icmp eq i64 %outer.iv.next, 1000
37 br i1 %cond2, label %bb9, label %outer.header
39 bb9: ; preds = %outer.latch