1; RUN: opt -loop-simplify -S < %s | FileCheck %s 2 3; CHECK-LABEL: @test1 4define void @test1(i32 %n) { 5entry: 6 br label %while.cond 7 8while.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 12 13while.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 17 18if.then: ; preds = %while.body 19 %add = add i32 %count.0, 1 20 br label %while.cond, !llvm.loop !0 21 22if.else: ; preds = %while.body 23 %add2 = add i32 %count.0, 2 24 br label %while.cond, !llvm.loop !0 25 26while.end: ; preds = %while.cond 27 ret void 28} 29 30; CHECK: if.then 31; CHECK-NOT: br {{.*}}!llvm.loop{{.*}} 32 33; CHECK: while.cond.backedge: 34; CHECK: br label %while.cond, !llvm.loop !0 35 36; CHECK: if.else 37; CHECK-NOT: br {{.*}}!llvm.loop{{.*}} 38 39; CHECK-LABEL: @test2 40; CHECK: for.body: 41; CHECK: br i1 %{{.*}}, label %for.body, label %cleanup.loopexit, !llvm.loop !0 42define void @test2(i32 %k) { 43entry: 44 %cmp9 = icmp sgt i32 %k, 0 45 br i1 %cmp9, label %for.body.preheader, label %cleanup 46 47for.body.preheader: ; preds = %entry 48 br label %for.body 49 50for.cond: ; preds = %for.body 51 %cmp = icmp slt i32 %inc, %k 52 br i1 %cmp, label %for.body, label %cleanup.loopexit, !llvm.loop !0 53 54for.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 59 60cleanup.loopexit: ; preds = %for.body, %for.cond 61 br label %cleanup 62 63cleanup: ; preds = %cleanup.loopexit, %entry 64 ret void 65} 66 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} 71