1 ; RUN: opt -simplifycfg -S < %s | FileCheck %s
3 declare void @bar() nounwind
5 define i32 @test1(i32* %a, i32 %b, i32* %c, i32 %d) nounwind {
7 %tobool = icmp eq i32 %b, 0
8 br i1 %tobool, label %if.else, label %if.then
10 if.then: ; preds = %entry
11 tail call void @bar() nounwind
14 if.else: ; preds = %entry
15 %tobool3 = icmp eq i32 %d, 0
16 br i1 %tobool3, label %if.end7, label %if.then4
18 if.then4: ; preds = %if.else
19 tail call void @bar() nounwind
22 if.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
27 ; CHECK-LABEL: @test1(
29 ; CHECK: br label %if.end7
31 ; CHECK: phi i32* [ %a, %if.then ], [ %c, %if.else ]
34 define i32 @test2(i32* %a, i32 %b, i32* %c, i32 %d) nounwind {
36 %tobool = icmp eq i32 %b, 0
37 br i1 %tobool, label %if.else, label %if.then
39 if.then: ; preds = %entry
40 tail call void @bar() nounwind
43 if.else: ; preds = %entry
44 %tobool3 = icmp eq i32 %d, 0
45 br i1 %tobool3, label %if.end7, label %if.then4
47 if.then4: ; preds = %if.else
48 tail call void @bar() nounwind
51 if.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
55 ; CHECK-LABEL: @test2(
62 define i32 @test3(i32* %a, i32 %b, i32* %c, i32 %d) nounwind {
64 %tobool = icmp eq i32 %b, 0
65 br i1 %tobool, label %if.else, label %if.then
67 if.then: ; preds = %entry
68 tail call void @bar() nounwind
71 if.else: ; preds = %entry
72 %tobool3 = icmp eq i32 %d, 0
73 br i1 %tobool3, label %if.end7, label %if.then4
75 if.then4: ; preds = %if.else
76 tail call void @bar() nounwind
79 if.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
84 ; CHECK-LABEL: @test3(
86 ; CHECK: phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ]
89 define i32 @test4(i32* %a, i32 %b, i32* %c, i32 %d) nounwind {
91 %tobool = icmp eq i32 %b, 0
92 br i1 %tobool, label %if.else, label %if.then
94 if.then: ; preds = %entry
95 tail call void @bar() nounwind
98 if.else: ; preds = %entry
99 %tobool3 = icmp eq i32 %d, 0
100 br i1 %tobool3, label %if.end7, label %if.then4
102 if.then4: ; preds = %if.else
103 tail call void @bar() nounwind
106 if.end7: ; preds = %if.else, %if.then4, %if.then
107 %x.0 = phi i32* [ %a, %if.then ], [ null, %if.then4 ], [ null, %if.else ]
108 %gep = getelementptr i32* %x.0, i32 10
109 %tmp9 = load i32* %gep
110 %tmp10 = or i32 %tmp9, 1
111 store i32 %tmp10, i32* %gep
113 ; CHECK-LABEL: @test4(