1 ; RUN: opt -passes=loop-simplify -S < %s | FileCheck %s
4 define void @test1(i32 %n) {
8 while.cond: ; preds = %if.then, %if.else, %entry
9 %count.0 = phi i32 [ 0, %entry ], [ %add, %if.then ], [ %add2, %if.else ]
10 %cmp = icmp ugt i32 %count.0, %n
11 br i1 %cmp, label %while.end, label %while.body
13 while.body: ; preds = %while.cond
14 %rem = and i32 %count.0, 1
15 %cmp1 = icmp eq i32 %rem, 0
16 br i1 %cmp1, label %if.then, label %if.else
18 if.then: ; preds = %while.body
19 %add = add i32 %count.0, 1
20 br label %while.cond, !llvm.loop !0
22 if.else: ; preds = %while.body
23 %add2 = add i32 %count.0, 2
24 br label %while.cond, !llvm.loop !0
26 while.end: ; preds = %while.cond
31 ; CHECK-NOT: br {{.*}}!llvm.loop{{.*}}
33 ; CHECK: while.cond.backedge:
34 ; CHECK: br label %while.cond, !llvm.loop !0
37 ; CHECK-NOT: br {{.*}}!llvm.loop{{.*}}
41 ; CHECK: br i1 %{{.*}}, label %for.body, label %cleanup.loopexit, !llvm.loop !0
42 define void @test2(i32 %k) {
44 %cmp9 = icmp sgt i32 %k, 0
45 br i1 %cmp9, label %for.body.preheader, label %cleanup
47 for.body.preheader: ; preds = %entry
50 for.cond: ; preds = %for.body
51 %cmp = icmp slt i32 %inc, %k
52 br i1 %cmp, label %for.body, label %cleanup.loopexit, !llvm.loop !0
54 for.body: ; preds = %for.body.preheader, %for.cond
55 %i.010 = phi i32 [ %inc, %for.cond ], [ 0, %for.body.preheader ]
56 %cmp3 = icmp sgt i32 %i.010, 3
57 %inc = add nsw i32 %i.010, 1
58 br i1 %cmp3, label %cleanup.loopexit, label %for.cond
60 cleanup.loopexit: ; preds = %for.body, %for.cond
63 cleanup: ; preds = %cleanup.loopexit, %entry
67 !0 = distinct !{!0, !1}
68 !1 = !{!"llvm.loop.distribute.enable", i1 true}
69 ; CHECK: !0 = distinct !{!0, !1}
70 ; CHECK: !1 = !{!"llvm.loop.distribute.enable", i1 true}