blob: 0615cd1fb3f2ac0eaf365e9a738c8a3d463de28e [file] [log] [blame]
Eric Christophercee313d2019-04-17 04:52:47 +00001; RUN: opt -simplifycfg -keep-loops=false -S < %s | FileCheck %s
2; RUN: opt -passes='simplify-cfg<no-keep-loops>' -S < %s | FileCheck %s
3
4define void @test1(i32 %n) #0 {
5entry:
6 %n.addr = alloca i32, align 4
7 %count = alloca i32, align 4
8 store i32 %n, i32* %n.addr, align 4
9 %0 = bitcast i32* %count to i8*
10 store i32 0, i32* %count, align 4
11 br label %while.cond
12
13while.cond: ; preds = %if.end, %entry
14 %1 = load i32, i32* %count, align 4
15 %2 = load i32, i32* %n.addr, align 4
16 %cmp = icmp ule i32 %1, %2
17 br i1 %cmp, label %while.body, label %while.end
18
19while.body: ; preds = %while.cond
20 %3 = load i32, i32* %count, align 4
21 %rem = urem i32 %3, 2
22 %cmp1 = icmp eq i32 %rem, 0
23 br i1 %cmp1, label %if.then, label %if.else
24
25if.then: ; preds = %while.body
26 %4 = load i32, i32* %count, align 4
27 %add = add i32 %4, 1
28 store i32 %add, i32* %count, align 4
29 br label %if.end
30
31; CHECK: if.then:
32; CHECK: br label %while.cond, !llvm.loop !0
33
34if.else: ; preds = %while.body
35 %5 = load i32, i32* %count, align 4
36 %add2 = add i32 %5, 2
37 store i32 %add2, i32* %count, align 4
38 br label %if.end
39
40; CHECK: if.else:
41; CHECK: br label %while.cond, !llvm.loop !0
42
43if.end: ; preds = %if.else, %if.then
44 br label %while.cond, !llvm.loop !0
45
46while.end: ; preds = %while.cond
47 %6 = bitcast i32* %count to i8*
48 ret void
49}
50
51!0 = distinct !{!0, !1}
52!1 = !{!"llvm.loop.distribute.enable", i1 true}
53; CHECK: !0 = distinct !{!0, !1}
54; CHECK: !1 = !{!"llvm.loop.distribute.enable", i1 true}