blob: 65d888ea01e107257936fff85924d9679348d478 [file] [log] [blame]
Benjamin Kramerfb212a62011-08-26 01:22:29 +00001; RUN: opt -simplifycfg -S < %s | FileCheck %s
2
3declare void @bar() nounwind
4
5define i32 @test1(i32* %a, i32 %b, i32* %c, i32 %d) nounwind {
6entry:
7 %tobool = icmp eq i32 %b, 0
8 br i1 %tobool, label %if.else, label %if.then
9
10if.then: ; preds = %entry
11 tail call void @bar() nounwind
12 br label %if.end7
13
14if.else: ; preds = %entry
15 %tobool3 = icmp eq i32 %d, 0
16 br i1 %tobool3, label %if.end7, label %if.then4
17
18if.then4: ; preds = %if.else
19 tail call void @bar() nounwind
20 br label %if.end7
21
22if.end7: ; preds = %if.else, %if.then4, %if.then
23 %x.0 = phi i32* [ %a, %if.then ], [ %c, %if.then4 ], [ null, %if.else ]
24 %tmp9 = load i32* %x.0
25 ret i32 %tmp9
26
27; CHECK: @test1
28; CHECK: if.else:
29; CHECK: br label %if.end7
30
31; CHECK: phi i32* [ %a, %if.then ], [ %c, %if.else ]
32}
33
34define i32 @test2(i32* %a, i32 %b, i32* %c, i32 %d) nounwind {
35entry:
36 %tobool = icmp eq i32 %b, 0
37 br i1 %tobool, label %if.else, label %if.then
38
39if.then: ; preds = %entry
40 tail call void @bar() nounwind
41 br label %if.end7
42
43if.else: ; preds = %entry
44 %tobool3 = icmp eq i32 %d, 0
45 br i1 %tobool3, label %if.end7, label %if.then4
46
47if.then4: ; preds = %if.else
48 tail call void @bar() nounwind
49 br label %if.end7
50
51if.end7: ; preds = %if.else, %if.then4, %if.then
52 %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ]
53 %tmp9 = load i32* %x.0
54 ret i32 %tmp9
55; CHECK: @test2
56; CHECK: if.else:
57; CHECK: unreachable
58
59; CHECK-NOT: phi
60}
61
62define i32 @test3(i32* %a, i32 %b, i32* %c, i32 %d) nounwind {
63entry:
64 %tobool = icmp eq i32 %b, 0
65 br i1 %tobool, label %if.else, label %if.then
66
67if.then: ; preds = %entry
68 tail call void @bar() nounwind
69 br label %if.end7
70
71if.else: ; preds = %entry
72 %tobool3 = icmp eq i32 %d, 0
73 br i1 %tobool3, label %if.end7, label %if.then4
74
75if.then4: ; preds = %if.else
76 tail call void @bar() nounwind
77 br label %if.end7
78
79if.end7: ; preds = %if.else, %if.then4, %if.then
80 %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ]
81 tail call void @bar() nounwind
82 %tmp9 = load i32* %x.0
83 ret i32 %tmp9
84; CHECK: @test3
85; CHECK: if.end7:
86; CHECK: phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ]
87}